v-for ESLint一直提示有问题不给过,但是我又看不出问题在哪各位大佬求指教
package是一个空数组,后端返回数据后push进去,页面显示一切正常,求大佬们指教
代码
具体的错误描述如下:
98% after emitting CopyPlugin
WARNING Compiled with 1 warnings 14:59:47
Module Warning (from ./node_modules/eslint-loader/index.js):
error: 'v-for' directives require that attribute value (vue/valid-v-for) at src/pages/order.vue:17:19:
15 | <el-row :gutter="20" type="flex" justify="space-between" style="flex-wrap:wrap;">
16 | <el-col
> 17 | v-for="item in package"
| ^
18 | :key="item.id"
19 | :xs="12"
20 | :sm="12"
error: Parsing error: Line 1: Unexpected reserved word 'package'
> 1 | for(let item in package);
| ^ (vue/no-parsing-error) at src/pages/order.vue:17:34:
15 | <el-row :gutter="20" type="flex" justify="space-between" style="flex-wrap:wrap;">
16 | <el-col
> 17 | v-for="item in package"
| ^
18 | :key="item.id"
19 | :xs="12"
20 | :sm="12"
error: Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive (vue/valid-v-for) at src/pages/order.vue:18:19:
16 | <el-col
17 | v-for="item in package"
> 18 | :key="item.id"
| ^
19 | :xs="12"
20 | :sm="12"
21 | :md="6"
3 errors found.
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因为
package
是js的保留字,所以报错。原因
reserved word 中文意思 "保留字"。eslint 认为 package 这个变量名是 js 里面的保留字。保留字是为以后js的扩展用的,不能作为普通变量名。查看js保留字
解决
给 package 变量改个名字即可。(别再取保留字或者关键字了哦~~)
package是保留字,变量名不能用保留字或关键词