美文网首页
JS中Unexpected identifier错误

JS中Unexpected identifier错误

作者: DecadeHeart | 来源:发表于2017-04-09 12:15 被阅读0次

    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}'

    相关文章

      网友评论

          本文标题:JS中Unexpected identifier错误

          本文链接:https://www.haomeiwen.com/subject/rfddattx.html