跳到主要内容

uni-app开发

微信小程序开发

使用vue3 vite ts uni-app uni-ui

小知识

  • 更改路由页面之后,需要重新运行一下

  • 750rpx * 1334rpx 全屏 iPhone6

  • view == div text==span

  • #ifdef H5

    #ifdef H5
    // 只在 H5 平台下编译的代码块
    console.log('This is running on H5 platform.');
    #endif

    // 这部分代码在所有平台都会编译
    console.log('This is common code for all platforms.');

uni-app 命令

  • 创建项目

npx degit dcloudio/uni-preset-vue#vite-ts uni-app-vue

  • 安装依赖

pnpm i

  • 清理依赖

pnpm store prune

  • 编译

pnpm dev:mp-weixin

  • 运行

Run method: open Weixin Mini Program Devtools, import dist\dev\mp-weixin run.

VSCODE插件相关资料

  • 这两个是用来检查ts

pnpm i -D @types/wechat-miniprogram @uni-helper/uni-app-types

  • 安装提示

pnpm i -D @uni-helper/uni-ui-types

问题处理

pnpm -i 报错处理

  • Error: Expected "0.17.19" but got "0.16.17"
  • registry.npmmirror.com+esbuild@0.17.19\node_modules\esbuild

pnpm install esbuild@0.17.19

真机调试,一块白屏

相关资料

eslintrc.json,.prettierc.json

  • manifest.json添加appid 和 settings

     "mp-weixin" : {
    "appid" : "xxxxxxxxxx",
    "setting" : {
    "urlCheck" : false,
    "es6" : true,
    "postcss" : true,
    "minified" : true
    },
    "usingComponents" : true
    },

    很重要 "es6" : true,,不然真机调试,就送你一块白屏

Cannot find name 'uni'.ts(2304)

pnpm add -D @types/uni-app

原文作者

解决pinia报hasInjectionContext问题

hasInjectContext报错

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,[渲染层网络层错误] Failed to load local image resource

if url is http:/ just one slash is wrong

快捷键

  • 智能提示

ctl+i

协议
本作品代码部分采用 Apache 2.0协议 进行许可。遵循许可的前提下,你可以自由地对代码进行修改,再发布,可以将代码用作商业用途。但要求你:
  • 署名:在原有代码和衍生代码中,保留原作者署名及代码来源信息。
  • 保留许可证:在原有代码和衍生代码中,保留Apache 2.0协议文件。
本作品文档部分采用 知识共享署名 4.0 国际许可协议 进行许可。遵循许可的前提下,你可以自由地共享,包括在任何媒介上以任何形式复制、发行本作品,亦可以自由地演绎、修改、转换或以本作品为基础进行二次创作。但要求你:
  • 署名:应在使用本文档的全部或部分内容时候,注明原作者及来源信息。
  • 非商业性使用:不得用于商业出版或其他任何带有商业性质的行为。如需商业使用,请联系作者。
  • 相同方式共享的条件:在本文档基础上演绎、修改的作品,应当继续以知识共享署名 4.0国际许可协议进行许可。