Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Perfumere opened this issue Jun 9, 2020 · 17 comments
Closed
Labels

Comments

@Perfumere
Copy link

Info

  • Platform: Win & Mac
  • Vetur version:0.24.0
  • VS Code version:April 2020 (version 1.45.1)

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.

@q788799660
Copy link

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

@octref
Copy link
Member

octref commented Jun 15, 2020

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

vetur.validation.template: false

@fightingcat
Copy link

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

@octref
Copy link
Member

octref commented Jul 5, 2020

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

@gk-shi
Copy link

gk-shi commented Aug 21, 2020

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

@Perfumere
Copy link
Author

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

@Perfumere
Copy link
Author

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

@gk-shi
Copy link

gk-shi commented Aug 21, 2020

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

@ghost
Copy link

ghost commented Oct 6, 2020

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

@yoyo930021
Copy link
Member

yoyo930021 commented Oct 7, 2020

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

@septe01
Copy link

septe01 commented Dec 29, 2020

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

vetur.validation.template: false

tks its solved for me

@ahm750
Copy link

ahm750 commented Jan 15, 2021

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.

@yoyo930021
Copy link
Member

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.

@ahm750
Copy link

ahm750 commented Jan 15, 2021

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!

@lijing666
Copy link

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

@yoyo930021
Copy link
Member

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

@lijing666
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants