typescript - Vue 3 模板根只需要一个 element.eslint-plugin-vue

标签 typescript vuejs3

在搭建一个 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
    }
};

最佳答案

我最终关闭了 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,

关于typescript - Vue 3 模板根只需要一个 element.eslint-plugin-vue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64867504/

相关文章:

angular - 让 angular-oauth2-oidc 从其他选项卡检索访问 token

javascript - 将 Angular 8 中的菜单状态更改为事件状态

typescript - 如何使用 Typescript 从数组动态构建枚举

laravel - 在 Laravel 中安装 vue 3.0

typescript - 类型 'Ref<never[]>[]' 上不存在属性

html - 如何在 Vue 路由器中定义要在组件内部使用的变量?

angular - TS2345 : Argument of type 'string | null' is not assignable to parameter of type 'string | UrlTree'

Angular2使用父组件中的单击事件切换子组件中的类

javascript - 将额外未使用的日期字段添加到自定义类型时,测试会引发错误 TS2322 和 TS2769

javascript - 如何在Vue3中播放mp3文件