微信小程序常用配置

193 阅读1分钟

Window中的配置项

navigationBarBackgroundColorHexColor#000000导航栏背景颜色,如"#000000"
navigationBarTextStyleStringwhite导航栏标题颜色,仅支持 black/white
navigationBarTitleTextString导航栏标题文字内容

image-20211108184646967.png

tabBar的配置 对象类型,配置项指定 tab 栏的表现,以及 tab 切换时显示的对应页面。

colorHexColortab 上的文字默认颜色
selectedColorHexColortab 上的文字选中时的颜色
backgroundColorHexColortab 的背景色
borderStyleStringblacktabbar上边框的颜色, 仅支持 black/white
listArraytab 的列表,最少2个、最多5个
positionStringbottom可选值 bottom、top
  • 当设置 position 为 top 时,将不会显示 icon
  • tabBar 中的 list 是一个数组,配置项最少2个、最多5个 tab,tab 按数组的顺序排序。 其中 list 接受一个数组,数组中的每个项都是一个对象,其属性值如下: pagePath | String | 是 | 页面路径,必须在 pages 中先定义 | | ---------------- | ------ | - | --------------------------------------------------------------------- | | text | String | 是 | tab 上按钮文字
    | iconPath | String | 否 | 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片 | | selectedIconPath | String | 否 | 选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效

img-22.jpg

配置pages

  1. 数组中第一项,为默认首页
  2. 添加不同的编译模式,去指定默认首页(特别说明:只在开发测试时使用,上线就不能生效了)

image-20200326191553599.png