1、创建uniapp项目(vue3-vite-ts版本)
指令:npx degit dcloudio/uni-preset-vue#vite-ts wxApp20231027(项目名称);
官网:uniapp.dcloud.net.cn/quickstart-…
2、安装三个插件:uni-create-view、uni-helper、uniapp小程序扩展;如下图:
3、TS配置
a、安装类型声明文件:pnpm i -D @types/wechat-miniprogram @uni-helper/uni-app-types
b、tsconfig.json写入配置":
compilerOptions": {
"types": ["@types/wechat-miniprogram","@uni-helper/uni-app-types"]
},
4、json注释问题
a、打开vsode设置
b、搜索:关联文件或者Association
c、添加项将manifest.json、pages.json设置成jsonc(非严格模式)
注意:如遇到tsconfig.json 报如下错误Option 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead(选项“importsNotUsedAsValues”已弃用,将在TypeScript 5.5中停止运行;请在compilerOption配置中增加"ignoreDeprecations": "5.0",来抵消此错误;请用“verbatimModuleSyntax”代替。)
compilerOptions": {
"ignoreDeprecations": "5.0"
}