【发布时间】:2021-02-28 05:04:38
【问题描述】:
在搭建 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
}
};
【问题讨论】:
-
请在此处添加完整的
.eslintrc.js。 -
我添加了 .eslintrc.js
-
嗯,这种类型的错误对我来说从来没有真正发生过。我能看到的唯一区别(与我的设置相比)是
extends部分。我正在使用标准 linter,而您似乎正在使用 Prettier。这些就是我要扩展的所有内容:plugin:vue/vue3-essential、@vue/standard、@vue/typescript/recommended,到目前为止,它们从未给我带来任何问题。 -
对我来说,问题不在于 eslint。我打开了一个文件夹,里面有很多项目。这样一来,eslint 就对验证一头雾水了。 Here 是 github 问题。
标签: typescript vuejs3