uni-app Development
WeChat Mini Program Developmentβ
Using vue3 vite ts uni-app uni-ui
Tipsβ
-
After changing the route page, you need to re-run it.
-
750rpx * 1334rpx Full screen iPhone6
-
view == div text==span
-
#ifdef H5
#ifdef H5
// Code block compiled only on H5 platform
console.log('This is running on H5 platform.');
#endif
// This part of code will be compiled on all platforms
console.log('This is common code for all platforms.');
uni-app Commandsβ
- Create Project
npx degit dcloudio/uni-preset-vue#vite-ts uni-app-vue
- Install Dependencies
pnpm i
- Prune Dependencies
pnpm store prune
- Compile
pnpm dev:mp-weixin
- Run
Run method: open Weixin Mini Program Devtools, import dist\dev\mp-weixin run.
VSCODE Plugin Related Information
- These two are for checking ts
pnpm i -D @types/wechat-miniprogram @uni-helper/uni-app-types
- Install Hints
pnpm i -D @uni-helper/uni-ui-types
Troubleshootingβ
pnpm -i Error Handlingβ
- Error: Expected "0.17.19" but got "0.16.17"
- [email protected]\node_modules\esbuild
pnpm install [email protected]
White Screen on Real Device Debuggingβ
eslintrc.jsonοΌ.prettierc.json
-
Add appid and settings to manifest.json
"mp-weixin" : {
"appid" : "xxxxxxxxxx",
"setting" : {
"urlCheck" : false,
"es6" : true,
"postcss" : true,
"minified" : true
},
"usingComponents" : true
},"es6" : true, is very important, otherwise real device debugging will give you a white screen
Cannot find name 'uni'.ts(2304)β
pnpm add -D @types/uni-app
Solve pinia hasInjectionContext errorβ
call with Alibaba OSS serviceβ
When upload a Gzip png picture,
and only set the ContentType header;
metadata.setContentType("image/png");
and not set
metadata.setContentEncoding("gzip");
anyway I had tried, the uni-app wechat miniprogram can't display the picture,
I make sure there source data.
wrong url, [Render Layer Network Layer Error] Failed to load local image resourceβ
if url is http:/ just one slash is wrong
Shortcutsβ
- IntelliSense
ctl+i
- Attribution: Retain the original author's signature and code source information in the original and derivative code.
- Preserve License: Retain the Apache 2.0 license file in the original and derivative code.
- Attribution: Give appropriate credit, provide a link to the license, and indicate if changes were made.
- NonCommercial: You may not use the material for commercial purposes. For commercial use, please contact the author.
- ShareAlike: If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.