When I use VS Code write Vue.js, the code color sometimes get chaos

Viewed 778

as shown below: enter image description here I don't understand why, the syntax and format is correct, it's extremely confusing.

I review my code carefully but can't figure out

2 Answers

this seems to be a bug with VS Code. This could be because VS Code is not updated, or an extension that is not supported anymore.

first, try ctrl + shift + p and running >Developer: Reload Window this should reload your current environment and the error should be fixed.

If that doesn't work, try a different extension. I currently use Vetur, and Prettier.

And don't forget to make sure your VS Code is up to date. go to the bottom left and click the settings cog, then check for update or updates.

My answer is, "Start from scratch, and record your steps." I'm happy to share my notes on what is presently working: https://github.com/TheAutomaTom/VsCodeSettings-Vue3

My personal machine had been in that spot for some weeks, so I took a step back and dump out your cornucopia of extensions and their dependencies.

  • Only run pertinent language services. This is a tall order given how much a Vue + Typescript + Tailwind on Vite app covers. I am suspicious of generalized HTML/CSS/JS packs though, because they may not be built to parse Vue SFCs. Every new release of a services intended for other frameworks, like Angular or React, are still possible culprits (and moving targets).

  • I gave up getting Prettier and ESLint on stable ground. For a non-workplace thing, I feel okay about that. You may be having issues with a global package, if you've been experimenting. I've tossed out a couple branches following different tutorials. I intend to revisit this one since it has some example projects: rvest.vs-code-prettier-eslint

  • I've noticed the Volar team seems to let oddities squeak out a little more frequently than I remember in Vetur.... but we love them just the way they are. Sometimes I downgrade just to check if I've gone crazy, yet.

Related