升级Vue + vite + TS 后报错,代码运行正常逻辑没问题, 就标红报错?

"vue": "^3.5.15" ,"typescript": "5.3.3","vite": "5.2.10"

报错位置: import { ref, onMounted, watch, nextTick } from "vue";

报错: 类似 模块“"vue"”没有导出的成员“ref”, 就这一个其他都正常,运行也是正常.

解决方式: 删缓存, 删mode 重装之类都试了,AI说删除 @vue/runtime-core 和 @vue/runtime- dom 但还是有这个报错.

报错显示:
WeChatc0f478faab51dac0f6eb77ccabaf0888.jpg

插件之类也排查过了:
截屏2025-05-28 06.57.54.png

截屏2025-05-28 06.59.54.png

截屏2025-05-28 07.00.15.png

截屏2025-05-28 07.01.41.png

/* package.json */
{
  "name": "vue_vite",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "vite --mode development",
    "build": "run-p type-check build-only",
    "dev": "vite --host",
    "preview": "vite preview",
    "build-only": "vite build",
    "type-check": "vue-tsc --noEmit",
    "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
    "format": "prettier --write src"
  },
  "dependencies": {
    "element-plus": "^2.9.9",
    "pinia": "^2.1.7",
    "terser": "^5.22.0",
    "vue": "^3.5.15",
    "vue-router": "^4.2.5"
  },
  "devDependencies": {
    "@highlightjs/vue-plugin": "^2.1.0",
    "@rushstack/eslint-patch": "^1.1.4",
    "@tinymce/tinymce-vue": "^5.1.0",
    "@types/lodash": "^4.14.191",
    "@types/node": "^20.10.6",
    "@types/postcss-pxtorem": "^6.1.0",
    "@types/qs": "^6.9.7",
    "@types/web-bluetooth": "^0.0.21",
    "@vicons/ionicons5": "^0.12.0",
    "@vitejs/plugin-vue": "^5.2.4",
    "@vue-flow/core": "^1.19.0",
    "@vue/eslint-config-prettier": "^7.0.0",
    "@vue/eslint-config-typescript": "^11.0.0",
    "@vue/tsconfig": "^0.7.0",
    "@vueup/vue-quill": "^1.1.1",
    "@vueuse/core": "^10.6.0",
    "@vueuse/motion": "^2.0.0",
    "@vueuse/rxjs": "^10.6.0",
    "amfe-flexible": "^2.2.1",
    "axios": "^1.6.7",
    "csstype": "3.1.2",
    "dayjs": "^1.11.8",
    "dexie": "^3.2.3",
    "echarts": "^5.4.4",
    "eslint": "^8.56.0",
    "eslint-plugin-vue": "^9.17.0",
    "highlight.js": "^11.7.0",
    "lodash": "^4.17.21",
    "mitt": "^3.0.0",
    "naive-ui": "^2.34.3",
    "npm-run-all": "^4.1.5",
    "openai": "^4.24.0",
    "pinia-plugin-persistedstate": "^3.2.0",
    "postcss-pxtorem": "^6.1.0",
    "prettier": "^3.2.5",
    "qs": "^6.11.0",
    "quill-blot-formatter": "^1.0.5",
    "quill-magic-url": "^4.2.0",
    "rollup": "^4.41.0",
    "rxjs": "^7.8.1",
    "sass": "^1.69.5",
    "typescript": "5.2.2",
    "unplugin-auto-import": "^19.1.2",
    "unplugin-vue-components": "^28.5.0",
    "unplugin-vue-macros": "^2.14.5",
    "vfonts": "^0.0.3",
    "vite": "5.2.10",
    "vue-echarts": "^6.5.4",
    "vue-i18n": "9.3.0-beta.16",
    "vue-tsc": "1.8.27",
    "vue3-cookies": "^1.0.6",
    "vuedraggable": "^4.1.0"
  },
  "overrides": {
    "typescript": "5.2.2"
  }
}
/* tsconfig.json */
{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "Node",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    },
    "lib": ["ESNext", "DOM"],
    "types": ["vite/client", "vue"],
    "useDefineForClassFields": true,
    "resolveJsonModule": true,
    "jsx": "preserve"
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}
阅读 334
1 个回答

问题解决了,就更新vue,TS不动就ok了

推荐问题