這篇文章主要介紹了微信小程序 開發(fā)之全局配置的相關(guān)資料,需要的朋友可以參考下
一.app.json
使用app.json文件來對(duì)微信小程序進(jìn)行全局配置,決定頁面文件的路徑、窗口表現(xiàn)、設(shè)置網(wǎng)絡(luò)超時(shí)時(shí)間、設(shè)置多 tab 等.
注意在.json不能注釋,否則會(huì)出錯(cuò)。
二.工具欄tabBar
如果我們的小程序是一個(gè)多 tab 應(yīng)用(客戶端窗口的底部或頂部有 tab 欄可以切換頁面),那么我們可以通過 tabBar 配置項(xiàng)指定 tab 欄的表現(xiàn),以及 tab 切換時(shí)顯示的對(duì)應(yīng)頁面。
tabBar 是一個(gè)數(shù)組,只能配置最少2個(gè)、最多5個(gè) tab,tab 按數(shù)組的順序排序
app.json中
{ "pages": ["pages/index/index", "pages/coming/coming", "pages/search/search", "pages/top/top" ], "window": { "navigationBarBackgroundColor": "#47a86c", "navigationBarTextStyle": "white", "navigationBarTitleText": "小程序案例", "backgroundColor": "#fff", "backgroundTextStyle": "dark" }, "tabBar": { "color": "#686868", "selectedColor": "#47a86c", "backgroundColor": "#fff", "list": [{ "pagePath": "pages/index/index", "iconPath": "dist/images/popular_icon.png", "selectedIconPath": "dist/images/popular_active_icon.png", "text": "熱映" }, { "pagePath": "pages/coming/coming", "iconPath": "dist/images/coming_icon.png", "selectedIconPath": "dist/images/coming_active_icon.png", "text": "待映" }, { "pagePath": "pages/search/search", "iconPath": "dist/images/search_icon.png", "selectedIconPath": "dist/images/search_active_icon.png", "text": "搜索" }, { "pagePath": "pages/top/top", "iconPath": "dist/images/top_icon.png", "selectedIconPath": "dist/images/top_active_icon.png", "text": "口碑" }] }, "networkTimeout": { "request": 10000, "downloadFile": 10000 }, "debug": true }
登錄后復(fù)制
圖標(biāo)可以放在與pages同級(jí),文件命名可是自定。
app.json中其他屬性:可以查看官方文檔。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,更多相關(guān)內(nèi)容請(qǐng)關(guān)注PHP中文網(wǎng)!
相關(guān)推薦:
以上就是微信小程序 開發(fā)之全局配置的介紹的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注有卡有網(wǎng)。