LayUI-使用table數據表格用thymeleaf解析報500錯誤

<script>
    layui.use('table', function(){
        var table = layui.table;

        table.render({
            elem: '#test'
            ,url:'/demo/table/user/'
            ,cellMinWidth: 80 //全局定義常規單元格的最小寬度,layui 2.2.1 新增
            ,cols: [[
                    {field:'id', width:80, title: 'ID', sort: true}
                    ,{field:'username', width:80, title: '用戶名'}
                    ,{field:'sex', width:80, title: '性別', sort: true}
                    ,{field:'city', width:80, title: '城市'}
                    ,{field:'sign', title: '簽名', width: '30%', minWidth: 100} //minWidth:局部定義當前單元格的最小寬度,layui 2.2.1 新增
                    ,{field:'experience', title: '積分', sort: true}
                    ,{field:'score', title: '評分', sort: true}
                    ,{field:'classify', title: '職業'}
                    ,{field:'wealth', width:137, title: '財富', sort: true}
                ]]
        });
    });
</script>

可以看到有一部分是

col[[
	... ...
]]

只需要改成

col[
	[
		... ...
	]
]
<script>
    layui.use('table', function(){
        var table = layui.table;

        table.render({
            elem: '#test'
            ,url:'/demo/table/user/'
            ,cellMinWidth: 80 //全局定義常規單元格的最小寬度,layui 2.2.1 新增
            ,cols: [
                [
                    {field:'id', width:80, title: 'ID', sort: true}
                    ,{field:'username', width:80, title: '用戶名'}
                    ,{field:'sex', width:80, title: '性別', sort: true}
                    ,{field:'city', width:80, title: '城市'}
                    ,{field:'sign', title: '簽名', width: '30%', minWidth: 100} //minWidth:局部定義當前單元格的最小寬度,layui 2.2.1 新增
                    ,{field:'experience', title: '積分', sort: true}
                    ,{field:'score', title: '評分', sort: true}
                    ,{field:'classify', title: '職業'}
                    ,{field:'wealth', width:137, title: '財富', sort: true}
                ]
            ]
        });
    });
</script>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章