Vetur: valid-template-root root requires exactly one element;vue3使用多根节点

Created on 9 Jun 2020  ·  17Comments  ·  Source: vuejs/vetur

Info

Problem

When I use vue-next,I got an error
What should I do to not see it
在模板使用多根节点,报错如下

// app.vue
<template>
    <demo-layout />
    <demo-container />
    <demo-menu />
    <demo-button />
</template>

[vue/valid-template-root]
The template root requires exactly one element.

question

Most helpful comment

https://vuejs.github.io/vetur/linting-error.html#linting-for-template

vetur.validation.template: false

All 17 comments

不影响正常使用,但是报错

https://vuejs.github.io/vetur/linting-error.html#linting-for-template

vetur.validation.template: false

Sorry for trolling this, but would it not be better if the plugin can discover the .eslintrc file?

Tracked in #2015. Now you can turn it off with "vetur.validation.template": false.

Have all of you solved this error prompt?Why do I still have this error prompt valid-template-root
I use the latest vscode (v1.48.1) and the latest vetur (0.26.1).😹
image

yeah,I had solved this error. just create dir named .vscode in the rootDir and then create file named settings.json in .vscode
image
@gk-shi

but now, the lasted vetur had no problem as I see.
Maybe you could update the plugin and restart VsCode
@gk-shi

the latest vetur is ok.

I found the reason of my problem.

I installed other plugin work for Wechat miniprogram, and it will check template block in the .vue files.... ̄□ ̄||

after turn off thems the vetur working correctly.

Thanks!😁
@Perfumere

Disable the whole template validation for the sake of fixing one warning? Is that a suggestion?

Disable the whole template validation for the sake of fixing one warning? Is that a suggestion?

The Vue 3 rules are now automatically used when Vue3.
You don't need disable it now.

And If you use eslint in project, you can disable it.
Let your project eslint replace it.
The two functions are the same.

https://vuejs.github.io/vetur/linting-error.html#linting

https://vuejs.github.io/vetur/linting-error.html#linting-for-template

vetur.validation.template: false

tks its solved for me

Disabling the template validation defeats the whole purpose of having Vetur.

I resolved the issue by moving the project to the root of the workspace. So if you're project is in a subfolder (e.g workspace > subfolder > project), Vetur looks for the package.json file in the subfolder and not in your project folder, hence the reason why it doesn't work properly.

Disabling the template validation defeats the whole purpose of having Vetur.

I resolved the issue by moving the project to the root of the workspace. So if you're project is in a subfolder (e.g workspace > subfolder > project), Vetur looks for the package.json file in the subfolder and not in your project folder, hence the reason why it doesn't work properly.

If you use subfolder and monorepo, you can use vetur.config.js.

Disabling the template validation defeats the whole purpose of having Vetur.
I resolved the issue by moving the project to the root of the workspace. So if you're project is in a subfolder (e.g workspace > subfolder > project), Vetur looks for the package.json file in the subfolder and not in your project folder, hence the reason why it doesn't work properly.

If you use subfolder and monorepo, you can use vetur.config.js.

This worked too, thanks!

Disabling the template validation defeats the whole purpose of having Vetur.

I resolved the issue by moving the project to the root of the workspace. So if you're project is in a subfolder (e.g workspace > subfolder > project), Vetur looks for the package.json file in the subfolder and not in your project folder, hence the reason why it doesn't work properly.

When my project is in a subfolder , node_modules modules with package.json has vetur tags or attributes config also not work

Disabling the template validation defeats the whole purpose of having Vetur.
I resolved the issue by moving the project to the root of the workspace. So if you're project is in a subfolder (e.g workspace > subfolder > project), Vetur looks for the package.json file in the subfolder and not in your project folder, hence the reason why it doesn't work properly.

When my project is in a subfolder , node_modules modules with package.json has vetur tags or attributes config also not work

Please use vetur.config.js.
https://vuejs.github.io/vetur/guide/setup.html#advanced

Disabling the template validation defeats the whole purpose of having Vetur.
I resolved the issue by moving the project to the root of the workspace. So if you're project is in a subfolder (e.g workspace > subfolder > project), Vetur looks for the package.json file in the subfolder and not in your project folder, hence the reason why it doesn't work properly.

When my project is in a subfolder , node_modules modules with package.json has vetur tags or attributes config also not work

Please use vetur.config.js.
https://vuejs.github.io/vetur/guide/setup.html#advanced

Thanks a lot, It works

Was this page helpful?
0 / 5 - 0 ratings