微信小程序 - JSON 配置 - window 配置 - tabBar 配置 --Y.

本文详细介绍了微信小程序中JSON配置文件的使用,重点讲解了window配置和tabBar配置。window配置用于设定状态栏、导航条、标题和窗口背景色,需要注意页面的.json只设置window相关项。而tabBar配置则涉及底部导航栏的设置,包括图标和文字,至少需要2个,最多5个tab,并对icon大小进行了规定。
摘要由CSDN通过智能技术生成
JSON 配置
配置文档:https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html

如:app.json

{
  "pages": [
    "pages/index/index",
    "pages/logs/logs"
  ],
  "window": {
    "navigationBarTitleText": "小程序标题"
  },
  "tabBar": {
    "list": [{
      "pagePath": "pages/index/index",
      "text": "首页"
    }, {
      "pagePath": "pages/logs/logs",
      "text": "Tab栏"
    }]
  },
  "networkTimeout": {
    "request": 10000,
    "downloadFile": 10000
  },
  "debug": true
}
window 配置

用于设置小程序的状态栏、导航条、标题、窗口背景色。

window 配置图示 ![这里写图片描述](https://img-blog.csdn.net/20180810170225737?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjU3NTM1NA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
window 配置注意事项 !! 注意:页面的.json只能设置 window 相关的配置项,以决定本页面的窗口表现,所以无需写 window 这个关键词。 如:/pages/message/message.json
    {
        "navigationBarBackgroundColor": "#ffffff",
        "navigationBarTextStyle": "black",
        "navigationBarTitleText": "内页标题修改",
        "backgroundColor": "#eeeeee",
        "backgroundTextStyle": "light"
    }
tabBar 配置
如果小程序是一个多 tab 应用(客户端窗口的底部或顶部有 tab 栏可以切换页面),可以通过 tabBar 配置项指定 tab 栏的表现,以及 tab 切换时显示的对应页面。 iconPath String 否 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效 selectedIconPath String 否 选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效
tabBar 配置图示

这里写图片描述

tabBar 配置注意事项
  1. 当设置 position 为 top 时,将不会显示 icon。
  2. tabBar 中的 list 是一个数组,只能配置最少2个、最多5个 tab,tab 按数组的顺序排序。
  3. icon 大小限制为40kb,建议尺寸为 81px * 81px。
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要通过请求网页获取信息并显示,你可以使用微信小程序提供的网络请求 API wx.request()。具体步骤如下: 1. 在小程序的 app.json 文件中配置要请求的网页域名,如: ``` "networkTimeout": { "request": 10000, "connectSocket": 10000, "uploadFile": 10000, "downloadFile": 10000 }, "debug": true, "networkTimeout": { "request": 10000, "connectSocket": 10000, "uploadFile": 10000, "downloadFile": 10000 }, "appid": "wx1234567890", "pages": [ "pages/index/index" ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#fff", "navigationBarTitleText": "小程序", "navigationBarTextStyle": "black" }, "tabBar": { "list": [ { "pagePath": "pages/index/index", "text": "首页" }, { "pagePath": "pages/about/about", "text": "关于" } ] }, "networkTimeout": { "request": 10000, "connectSocket": 10000, "uploadFile": 10000, "downloadFile": 10000 }, "permission": { "scope.userLocation": { "desc": "小程序需要获取你的地理位置" } }, "window": { "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black", "navigationBarTitleText": "小程序", "backgroundColor": "#eeeeee", "backgroundTextStyle": "light" }, "sitemapLocation": "sitemap.json", "requiredBackgroundModes": ["audio"] ``` 2. 在小程序的 js 文件中使用 wx.request() 方法请求网页,并获取数据,如: ``` wx.request({ url: 'https://www.example.com/data.json', success: function(res) { console.log(res.data) } }) ``` 3. 将获取到的数据显示在小程序的界面上,如: ``` Page({ data: { info: '' }, onLoad: function() { var that = this wx.request({ url: 'https://www.example.com/data.json', success: function(res) { that.setData({ info: res.data }) } }) } }) ``` 其中,info 是一个数据绑定变量,用来保存从网页获取的数据。在 onLoad 方法中,使用 that.setData() 方法将获取到的数据更新到界面上。在小程序的 wxml 文件中,可以使用 {{info}} 引用该数据绑定变量,将数据显示在界面上。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值