dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
40.1k stars 3.63k forks source link

vite types uni. 类型自动完成 无效 #3708

Closed reaink closed 2 years ago

reaink commented 2 years ago

现状及问题 类型并没有检测到

image

tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "useDefineForClassFields": true,
    "module": "esnext",
    "moduleResolution": "node",
    "strict": true,
    "jsx": "preserve",
    "sourceMap": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "allowJs": true,
    "lib": [
      "esnext",
      "dom"
    ],
    "types": [
      "@dcloudio/types",
      "wechat-miniprogram"
    ],
    "allowSyntheticDefaultImports": true,
    "paths": {
      "~/*": [
        "./src/*"
      ],
    }
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.d.ts",
    "src/**/*.tsx",
    "src/**/*.vue"
  ]
}

版本信息

    "@dcloudio/uni-app": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-app-plus": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-components": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-h5": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-mp-alipay": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-mp-baidu": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-mp-lark": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-mp-qq": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-mp-weixin": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-quickapp-webview": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-ui": "^1.4.19",

    "@dcloudio/types": "^3.0.8",
    "@dcloudio/uni-automator": "3.0.0-alpha-3050220220715001",
    "@dcloudio/uni-cli-shared": "3.0.0-alpha-3050220220715001",
    "@dcloudio/vite-plugin-uni": "3.0.0-alpha-3050220220715001",
xiaowu2333 commented 2 years ago

怎么解决的呢

reaink commented 2 years ago

@xiaowu2333 手动引入 import '@dcloudio/types'

xiaowu2333 commented 2 years ago

@xiaowu2333 手动引入 import '@dcloudio/types'

每次使用的地方都手动引入吗

reaink commented 2 years ago

类型提示,只需要在开始的其他引入一次就可以了

xiaowu2333 commented 2 years ago

类型提示,只需要在开始的其他引入一次就可以了

好咧 多谢您

xiaowu2333 commented 2 years ago

最终我这边的情况是 因为我使用了vscode开发,使用了vue3,所以使用了Volar插件 最后把插件的版本降到 0.39.1之后 解决了问题

image