JS中Unexpected identifier錯誤

JS中Unexpected identifier錯誤
錯誤提示:
Uncaught SyntaxError: Unexpected identifier

錯誤緣由:
通常是js代碼中書寫不規範形成錯誤,例如少了一個逗號、分號,或雙引號裏面包含了雙引號等等容易忽視的錯誤。

舉例:
本項目利用spring mvc的model存值,model("items",items),items爲string類型的字符串,例如{"total":1,"rows":[]};

在jsp中javascript要使用這個值,取值方法  var items = "${items}",這時會出現Unexpected identifier錯誤,緣由是雙引號裏面包含了雙引號;

解決方法是把雙引號改成單引號,即 var items = '${items}'

javascript

來源: <http://www.myexception.cn/javascript/1400921.html>html

相關文章
相關標籤/搜索