安装pnpm i -D @types/wechat-miniprogram报错,版本不匹配
在使用vscode和微信小程序配合写项目的时候,安装插件:
"@types/wechat-miniprogram",
出现报错,可能是代码写错了,少了一个s, types
另外会出现这两个错误
措施:
此时我们反其道而行,直接把他们都写上就行啦
"compilerOptions": {"importsNotUsedAsValues": "remove","preserveValueImports": false,"verbatimModuleSyntax": false,"strict": true,"sourceMap": true,"allowJs": true,"moduleResolution": "node","baseUrl": ".","paths": {"@/*": ["./src/*"]},"lib": ["esnext","dom"],"types": ["@dcloudio/types","@types/wechat-miniprogram","@uni-helper/uni-ui-types","@uni-helper/uni-app-types"]},
另外,还可以安装扩展插件
微信小程序插件(WeChat Mini Program):此插件提供了微信小程序的语法高亮、代码提示、调试、上传等功能。
直接在拓展上搜即可