Vue Language Features (Volar) 会引起ts报错

困扰了好一阵子的问题。

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "vue-cli-service serve",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "@liveqing/liveplayer": "^2.1.7",
    "@types/jquery": "^3.5.6",
    "@vue/runtime-dom": "^3.2.34",
    "axios": "^0.21.1",
    "copy-webpack-plugin": "4.6.0",
    "core-js": "^3.6.5",
    "echarts": "5.0.2",
    "echarts-gl": "^2.0.4",
    "echarts-liquidfill": "^3.0.0",
    "element-ui": "^2.15.1",
    "jquery": "^3.6.0",
    "moment": "^2.29.1",
    "postcss-px2rem": "^0.3.0",
    "tslib": "^2.3.1",
    "vue": "^2.6.11",
    "vue-router": "^3.2.0",
    "vuex": "^3.4.0"
  },
  "devDependencies": {
    "@types/echarts": "^4.1.3",
    "@typescript-eslint/eslint-plugin": "^5.25.0",
    "@typescript-eslint/parser": "^5.25.0",
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-typescript": "^4.5.17",
    "@vue/cli-plugin-vuex": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/eslint-config-typescript": "^10.0.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^6.0.0",
    "eslint-plugin-standard": "^5.0.0",
    "file-loader": "^6.2.0",
    "less": "^4.1.2",
    "less-loader": "^10.2.0",
    "node-sass": "4.14.1",
    "sass-loader": "7.3.1",
    "typescript": "^4.6.4",
    "vue-class-component": "^6.3.2",
    "vue-property-decorator": "^9.1.2",
    "vue-template-compiler": "^2.6.11"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

在vue2.6配合ts使用vscode volar插件报错。
Vue Language Features (Volar) 会引起ts报错_第1张图片
不知道是vue2的原因,可能兼容问题。
vue2常用插件
Vue Language Features (Volar) 会引起ts报错_第2张图片

volar 和 vetur

在功能上 volar 和 vetur 是一致的,都是针对 vue 的插件,但是 volar 的功能却要强大得多
可以这样说, volar 是 vue3 的配套,vetur 是 vue2 的配套,所以,建议大家在使用的时候依据自己使用的 vue 版本来选择。

你可能感兴趣的:(typescript,vscode,vue.js,javascript,前端)