日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

thymeleaf 使用javascript定义数组报错

發布時間:2023/12/18 javascript 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 thymeleaf 使用javascript定义数组报错 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

js中免不了的要用的數組,一維的二維的三維的

但是當用到thymeleaf作為模版時候會有一些坑,導致數組不能用

org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: " {checkbox: true, fixed: true}, {field: 'originalFileName', title: '文件名', width: 400, sort: true}, {field: 'fileType', title: '文件類型', width: 100}, {field: 'fileSize', title: '文件大小', width: 110, sort: true}, {field: 'createTime', title: '上傳時間', width: 170, sort: true}, {field: 'dpStatus', title: '數據處理狀態', width: 122, templet: '#statusTpl', sort: true}, {field: 'updateTime', title: '數據處理完成時間', width: 170, templet: '#updateTimeTpl', sort: true}, {fixed: 'right', title: '操作', align: 'center', width: 300, toolbar: '#operating'}" (template: "textManagement" - line 125, col 22)at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:131)at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:62)at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:44)at org.thymeleaf.engine.EngineEventUtils.parseAttributeExpression(EngineEventUtils.java:220)

這里只接觸最外層異常,而出現異常的位置

<script>var cols=[[{field:'checkBox',checkbox: true, fixed: true},{field:'username', title: '用戶名'} //width 支持:數字、百分比和不填寫。你還可以通過 minWidth 參數局部定義當前單元格的最小寬度,layui 2.2.1 新增,{field:'mobile', title: '手機號', sort: true},{field:'nickname', title: '昵稱'},{field:'lastLoginTime', title: '最后登錄時間'},{field:'ip', title: '最后登錄ip', align: 'center'} //單元格內容水平居中,{field:'op',title: '操作', align:'center', toolbar: '#toolBars'} //這里的toolbar值是模板元素的選擇器 ]]; </script>

?

thymeleaf會把[[]]中的內容作為內聯取值塊解析,而不是數組??梢栽赾ols的后面換行

解決辦法:
方法一:回車換行如下:

, cols: [[ //表頭{field: 'xxx', title: 'ID', width: 80, sort: true, fixed: 'left'}, {field: 'xxx', title: '記錄日期', width: 80}, {field: 'xxx', title: '操作人ID', width: 80, sort: true}, {field: 'xxx', title: '', width: 80}, {field: 'xxx', title: '簽名', width: 177}, {field: 'xxx', title: '積分', width: 80, sort: true}, {field: 'xxx', title: '評分', width: 80, sort: true}, {field: 'xxx', title: '職業', width: 80}, {field: 'xxx', title: '財富', width: 135, sort: true}]]

方法二:或者在script標簽里 th:inline="none" 就可以了,默認是th:inline="text"

<script th:inline="none"> </script>

?

轉載于:https://www.cnblogs.com/schoolbag/p/9679014.html

總結

以上是生活随笔為你收集整理的thymeleaf 使用javascript定义数组报错的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。