Vue 3 模板根只需要一个 element.eslint-plugin-vue [英] Vue 3 The template root requires exactly one element.eslint-plugin-vue
本文介绍了Vue 3 模板根只需要一个 element.eslint-plugin-vue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在搭建一个 Vue 3 项目后,我注意到我的 App.vue 中有一个错误.
After scafolding a Vue 3 project I noticed a error in my App.vue.
A functional component that renders the matched component for the given path. Components rendered in can also contain its own , which will render components for nested paths.
API Reference
[vue/no-multiple-template-root]
The template root requires exactly one element.eslint-plugin-vue
我试过了
"vue/no-multiple-template-root": 0
在我的 .eslintrc.js 中
in my .eslintrc.js
但错误仍然存在.我怎样才能摆脱错误?因为在 Vue 3 中,模板中不必只有一个元素.
But the error remains. How can I get rid of the error? Since in Vue 3 you don't have to have exactly one element in a template.
module.exports = {
root: true,
env: {
node: true
},
extends: [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint"
],
parserOptions: {
ecmaVersion: 2020
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"vue/no-multiple-template-root": 0
}
};
推荐答案
我最终关闭了 Vetur linting.Vetur 认为它是一个 Vue 2 项目,因为它位于 VS Code 工作区中.
I ended up turning off Vetur linting. Vetur thinks that it is a Vue 2 project becuase it is in a VS Code workspace.
https://github.com/vuejs/vetur/issues/2299#issuecomment-696015374
你可以通过这样做来解决这个问题
You can solve this by doing
F1>Preferences:Open Settings (JSON)
粘贴
"vetur.validation.template": false,
"vetur.validation.script": false,
"vetur.validation.style": false,
这篇关于Vue 3 模板根只需要一个 element.eslint-plugin-vue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文