cora1989 发表于 2020-12-10 09:06

微信小程序开发(全局配置文件)

本帖最后由 cora1989 于 2020-12-10 09:08 编辑

全局配置文件指:app.json

pages字段作用:控制页面目录在小程序开发时,每个页面都对应一个目录,每个目录又分别有wxml、wxss、js和json四个文件。详细说明可查看后续文章介绍,本文主要详解全局配置文件。该字段内容是一个字符串形式数组,数组中每一个元素代表一个页面。快捷键CTRL+S保存后会自动生成对应目录和页面

window字段控制小程序顶部背景颜色,标题等
<font size="3" face="微软雅黑">"window":{
    "backgroundTextStyle":"light",
    "navigationBarBackgroundColor": "#eb4450",
    "navigationBarTitleText": "标题名称",
    "navigationBarTextStyle":"white"
},</font>

backgroundTextStyle:下拉 loading 的样式,仅支持 dark / light。navigationBarBackgroundColor:导航栏背景颜色,如 #000000。navigationBarTitleText:导航栏标题文字内容。navigationBarTextStyle:导航栏标题颜色,仅支持 black / white。更多属性请移步微信开放文档中查看。
tabbar字段
控制导航条的。
<font size="3" face="微软雅黑">"tabBar": {
    "color": "#999",
    "selectedColor": "#ff2d4a",
    "backgroundColor": "#fafafa",
    "position": "bottom",
    "borderStyle": "black",
    "list": [
      {
      "pagePath": "pages/index/index",
      "text": "首页",
      "iconPath": "./icon/主页0.png",
      "selectedIconPath": "./icon/主页1.png"
      },
      {
      "pagePath": "pages/category/index",
      "text": "分类",
      "iconPath": "./icon/分类0.png",
      "selectedIconPath": "./icon/分类1.png"
      },
      {
      "pagePath": "pages/cart/index",
      "text": "购物车",
      "iconPath": "./icon/购物车0.png",
      "selectedIconPath": "./icon/购物车1.png"
      },
      {
      "pagePath": "pages/user/index",
      "text": "我的",
      "iconPath": "./icon/我的0.png",
      "selectedIconPath": "./icon/我的1.png"
      }
    ]
},</font>


color:tab 上的文字默认颜色,仅支持十六进制颜色。
selectedColor:tab 上的文字选中时的颜色,仅支持十六进制颜色。backgroundColor:tab 的背景色,仅支持十六进制颜色。position:tabBar 的位置,仅支持 bottom / top。borderStyle:tabbar 上边框的颜色, 仅支持 black / white。
list属性
pagePath:指定点击后要跳转的页面路径text:显示的页面名称iconPath:未被点击时的图标图片selectedIconPath:被点击后的图标图片

刘宇华 发表于 2020-12-10 09:06

多谢分享多谢分享

来龙考虑考虑 发表于 2020-12-10 09:09

6666666666

a47785788 发表于 2020-12-10 09:24

6666

h1098583853 发表于 2020-12-10 09:25

正需要,支持楼主,在大牛我只看好你!

cq1997 发表于 2020-12-10 09:34

感谢楼主分享

dusos 发表于 2020-12-10 09:58

谢谢分享

故事情节 发表于 2020-12-10 10:07

谢谢大佬分享

q404023244 发表于 2020-12-10 10:07

谢谢分享!

So-Tz. 发表于 2020-12-10 11:25


感谢楼主的分享
页: [1] 2
查看完整版本: 微信小程序开发(全局配置文件)