VS Code 在模板标签上显示错误

Lab*_*ks. 7 visual-studio vue.js

请问有人知道如何解决这个错误吗?

TypeScript intellisense is disabled on template. To enable, configure `"jsx": "preserve"` in the `"compilerOptions"` property of tsconfig or jsconfig. To disable this prompt instead, configure `"experimentalDisableTemplateSupport": true` in `"vueCompilerOptions"` property.volar
Run Code Online (Sandbox Code Playgroud)

Xpl*_*oit 12

在 jsconfig.json 中

    {
  "compilerOptions": {
    "target": "es5",
    "module": "esnext",
    "baseUrl": "./",
    "moduleResolution": "node",
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ],
    "jsx": "preserve"
  }
}
Run Code Online (Sandbox Code Playgroud)

写 --> "jsx": "保留"


Mic*_*sen 10

您需要"jsx": "preserve"在该部分下添加到您的配置中compilerOptions。根据您的项目设置方式,这会略有不同。

这是官方推荐的解决方案

如果您使用的是,.tsconfig它将如下所示:

{
  "compilerOptions": {
    "jsx": "preserve"
  }
}
Run Code Online (Sandbox Code Playgroud)

使用 Nuxt 3,你.tsconfig会看到更接近这个:

{
  // https://v3.nuxtjs.org/concepts/typescript
  "extends": "./.nuxt/tsconfig.json",
  "compilerOptions": {
    "jsx": "preserve"
  }
}
Run Code Online (Sandbox Code Playgroud)

如果您使用的是,.jsconfig那么它会更像这样:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "jsx": "preserve"
  },
  "include": ["src/**/*"]
}
Run Code Online (Sandbox Code Playgroud)

我在这里写了一篇关于解决此问题的简短博客文章:michaelnthiessen.com/typescript-intellisense-error


小智 6

在文件jsconfig.json上

添加:

"vueCompilerOptions": { "experimentalDisableTemplateSupport": true },