错误截图:
错误代码:
table.render({
elem: '#demo'
,height: 312
,url: '/list' //数据接口
,page: true //开启分页
,cols: [[ //表头
{field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
,{field: 'username', title: '用户名', width:80}
,{field: 'password', title: '密码', width:80, sort: true}
,{field: 'email', title: '邮箱', width:80}
,{field: 'status', title: '状态', width: 177}
,{field: 'code', title: 'uuid', width: 80, sort: true}
]]
});
});
错误原因:
因为[[…]]之间的表达式在thymeleaf被认为是内联表达式,所以渲染错误
解决方法:
把cols后的[[ ]]变为
[
[
]
]
正确代码:
table.render({
elem: '#demo'
,height: 312
,url: '/list' //数据接口
,page: true //开启分页
,cols: [
[ //表头
{field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
,{field: 'username', title: '用户名', width:80}
,{field: 'password', title: '密码', width:80, sort: true}
,{field: 'email', title: '邮箱', width:80}
,{field: 'status', title: '状态', width: 177}
,{field: 'code', title: 'uuid', width: 80, sort: true}
]
]
});
});