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.
阅读 10.2k
3 个回答

因为package 是js的保留字,所以报错。

原因

Unexpected reserved word 'package'

reserved word 中文意思 "保留字"。eslint 认为 package 这个变量名是 js 里面的保留字。保留字是为以后js的扩展用的,不能作为普通变量名。查看js保留字

解决

给 package 变量改个名字即可。(别再取保留字或者关键字了哦~~)

package是保留字,变量名不能用保留字或关键词

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏