Thymeleaf and layui table rendering conflict

Table rendering error in layui, conflict with Thymeleaf syntax

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}
            ]]
        });

Attention [[ ]]

In Thymeleaf is a grammar

If you want to use [[ ]] in js

The official document states that it is necessary to add th:inline="none" to the tag that references js

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

Add another better method, without grammatical conflicts


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

Guess you like

Origin blog.csdn.net/qq_39906884/article/details/85269374