在搭建了一个Vue 3项目后,我注意到我的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中
但是错误仍然存在。我怎样才能摆脱这个错误呢?因为在Vue 3中,一个模板中不需要只有一个元素。
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
}
};
发布于 2020-11-19 05:31:01
我最终关闭了Vetur linting。Vetur认为它是一个Vue 2项目,因为它在VS Code工作区中。
https://github.com/vuejs/vetur/issues/2299#issuecomment-696015374
您可以通过执行以下操作来解决此问题
F1>Preferences:Open Settings (JSON)
粘贴
"vetur.validation.template": false,
"vetur.validation.script": false,
"vetur.validation.style": false,
发布于 2021-11-01 21:06:51
这个错误发生在我身上,因为我没有在VS中打开项目根目录,而是打开了父文件夹,因此Vetur在这个文件夹中查找package.json
。
发布于 2021-03-03 06:26:04
这里用到了这个:
在.eslintrc.js中
而不是:
rules: { "vue/no-multiple-template-root": 0 }
尝试:
rules: {"vue/no-multiple-template-root": "off" }
https://stackoverflow.com/questions/64867504
复制相似问题