Thymeleaf 与 layui表格渲染冲突

layui中表格渲染报错, 与Thymeleaf语法冲突

table.render({
    
    
             elem: '#fileList'
            // ,height: 318
            ,url: 'testTable.json' //数据接口
            ,page: true //开启分页
            ,id: 'testReload'
            ,toolbar: '#toolbarDemo'
            ,cols: [[
                {
    
    type:'checkbox', fixed: 'left'}
                ,{
    
    field: 'id', title: 'ID', sort: true,width:80}
                ,{
    
    field: 'userId', title: '所属人',width:80, sort: true}
                ,{
    
    field: 'name', title: '文件名',edit: 'text',width:160 }
                ,{
    
    field: 'type', title: '类型',edit: 'text',width:80, sort: true}
                ,{
    
    field: 'size', title: '大小(KB)',width:100, sort: true}
                ,{
    
    field: 'gmtCreate', title: '上传时间',width:200, sort: true}
                ,{
    
    fixed: 'right', title:'操作', toolbar: '#fun', width:160}
            ]]
        });

注意 [[ ]]

在Thymeleaf中是一种语法

如果想在js中用到 [[ ]]

官方文档中说明需要在引用js的标签中加入th:inline=“none”

<script type="text/javascript" th:inline="none">
/**
	可以正确使用[[ ]]
**/
</script>

补充另外一种更好的方法, 不会语法冲突


<script type="text/javascript">
[[]]
变为
[
	[
		/*something*/
	]
]
</script>

猜你喜欢

转载自blog.csdn.net/qq_39906884/article/details/85269374
今日推荐