vue template 里使用可选链操作符( ?. )报错:Errors compiling template:invalid expression: Unexpected token ‘.‘ i |
您所在的位置:网站首页 › Vue类名报错 › vue template 里使用可选链操作符( ?. )报错:Errors compiling template:invalid expression: Unexpected token ‘.‘ i |
问题
我使用的node 版本是 12.13.0,vue 版本是 2.6.11,在 vue template 里使用可选链操作符( ?. )报错如下: 可选链操作符 {{testObj?.blog1?.name}} export default { name: "App", data() { return { testObj: {} } }, mounted() { this.testObj = { blog: { name: "kaimo313" } } }, };
这个问题主要是 vue 2.6.11 template 不支持可选链操作符,在可以升级 vue 版本的情况下,我们可以升级到 2.7.0 版本,同时 node 版本升级到 14.0.0。 npm i [email protected] [email protected]
一定要确定好 vue 版本的问题,可以去依赖里面看看版本,2.7.10 我也测试了一下,也是可行的 另外就是版本的问题了:node.js模块依赖及版本号 拓展: https://github.com/npm/node-semver#versions What’s the difference between tilde(~) and caret(^) in package.json? |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |