Skip to content

常见问题

下载基础库版本 x.x.x 失败

  1. 不要使用游客模式
  2. 设置 -> 代理 -> 不使用任何代理,勾选后直连网络
  3. 清缓存 -> 全部清除
  4. 详情 -> 本地设置 -> 调试基础库版本(降低版本)

将模拟器设置到右边?

设置 -> 外观 -> 模拟器位置 -> 右侧

指定初始化加载页面

更改 app.json 中的 pages 字段

初始加载页就把它的路径放在第一位:

json
{
  "pages": [
    "pages/test-page1/test-page1",
    "pages/index/index",
    "pages/test-page2/test-page2",
    "pages/test-page3/test-page3"
  ]
}

添加编译模式,自定义编译条件

condition

自定义导航栏的注意事项

custom navbar

常见高度参考:

js
// 状态栏高度
const statusBarHeight = wx.getSystemInfoSync().statusBarHeight
// 胶囊高度
const menuButtonHeight = wx.getMenuButtonBoundingClientRect().height
// 胶囊上方间距(胶囊顶部到状态栏底部的距离)
const capsuleTopGap = wx.getMenuButtonBoundingClientRect().top - wx.getSystemInfoSync().statusBarHeight

// 导航栏总高度
const navHeight = statusBarHeight + menuButtonHeight + capsuleTopGap * 2

集成 ant design mini

  1. 安装依赖

    bash
    npm i antd-mini --save
  2. 工具 -> 构建 npm

  3. 在页面配置的 usingComponents 字段中引入 antd-mini 组件

    json
    {
      "usingComponents": {
        "ant-button": "antd-mini/Button/index"
      }
    }
  4. 在页面中使用 antd-mini 组件

    xml
    <ant-button type="primary" bindtap="handleTap">主要按钮</ant-button>

样式问题

尺寸单位

rpx 是小程序新增的自适应单位,小程序规定,任何型号的手机的屏幕宽度都为 750rpx

background-image

小程序中的 background-image 不支持本地路径!需要使用网络图片,或者 base64,或者 <image> 组件。

基于 MIT 许可发布