irpas技术客

Vue报错 Variable ‘scope‘ is already declared in the upper scope_zihong2019

未知 2363

Vue报错 Variable ‘scope’ is already declared in the upper scope’


项目场景:

Vue "vue": "2.6.10", Eslint : "eslint": "6.7.2", eslint-plugin-vue : "eslint-plugin-vue": "6.2.2",

问题描述: <el-table :data="..." ... > <el-table-column align="center" type="expand" width="160" label="详细信息"> <template slot-scope="scope"> <el-table :data="scope.row.x" ... > </el-table> </template> </el-table-column> </el-table>

npm run link会报错:

$ npm run link > eslint --ext .js,.vue src /Users/xxx/Desktop/project/web/..../xxx.vue xxx:xxx warning Variable 'scope' is already declared in the upper scope vue/no-template-shadow ...
原因分析: eslint 报的错,提示的是vue/no-template-shadow搜了一下这个是eslint-plugin-vue中的规则,也就是.eslintrc.js文件中引入的extends: ['plugin:vue/recommended'],里面的规则查看详细文档地址 。 解决方案:

.eslintrc.js中修改如下

rules: { 'vue/no-template-shadow':'off', }

就不会再报错了。


1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。

标签: #Vue报错 #variable #Scope #is #already #declared #in #The