欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序開發(fā)app.json全局配置實(shí)戰(zhàn)指南

 更新時(shí)間:2023年05月31日 11:40:11   作者:哆啦A夢的異次元口袋  
app.json文件是小程序的全局配置文件,下面這篇文章主要給大家介紹了關(guān)于微信小程序開發(fā)app.json全局配置的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下

JSON 是一種數(shù)據(jù)格式,在實(shí)際開發(fā)中,JSON 總是以配置文件的形式出現(xiàn)。

app.json 是當(dāng)前小程序的全局配置,可以通過app.json對小程序項(xiàng)目進(jìn)行設(shè)置所有頁面路徑、窗口外觀、界面表現(xiàn)、底部 tab 等。

{
  "pages": [
    "pages/index/index",
    "pages/mine/mine",
    "pages/play/play",
    "pages/mycard/mycard",
    "pages/Record/Record",
    "pages/prize/prize",
    "pages/details/details",
    "pages/lottery/lottery",
    "pages/ar/ar"
  ],
  "window": {
    "backgroundTextStyle": "light",
    "navigationBarBackgroundColor": "#fff",
    "navigationBarTitleText": "我是展示標(biāo)題",
    "navigationBarTextStyle": "black"
  },
  "tabBar": {
    "backgroundColor": "#FFFFFF",
    "color": "#181818",
    "selectedColor": "#221415",
    "list": [
      {
        "pagePath": "pages/ar/ar",
        "iconPath": "images/tabbar/arg.png",
        "selectedIconPath": "images/tabbar/AR.png",
        "text": "AR"
      },
      {
        "pagePath": "pages/play/play",
        "iconPath": "images/tabbar/play.png",
        "selectedIconPath": "images/tabbar/playg.png",
        "text": "玩法"
      },
      {
        "pagePath": "pages/index/index",
        "iconPath": "images/tabbar/mine.png",
        "selectedIconPath": "images/tabbar/my.png",
        "text": "我的"
      }
    ]
  },
  "usingComponents": {
    "van-image": "@vant/weapp/image/index",
    "van-field": "@vant/weapp/field/index",
    "van-divider": "@vant/weapp/divider/index",
    "van-button": "@vant/weapp/button/index",
    "van-toast": "@vant/weapp/toast/index"
  },
  "requiredPrivateInfos": [
    "getLocation"
  ],
  "permission": {
    "scope.userLocation": {
      "desc": "你的位置信息將用于小程序位置接口的效果展示"
    }
  },
  "sitemapLocation": "sitemap.json"
}

pages配置項(xiàng)是一個(gè)數(shù)組,主要用于記錄頁面路徑。

第一項(xiàng)路徑是小程序默認(rèn)進(jìn)入的首頁

  "pages": [
    "pages/index/index",
    "pages/mine/mine",
    "pages/play/play",
    "pages/mycard/mycard",
    "pages/Record/Record",
    "pages/prize/prize",
    "pages/details/details",
    "pages/lottery/lottery",
    "pages/ar/ar"
  ],

window配置項(xiàng)主要用于更改所有頁面的狀態(tài)欄、導(dǎo)航欄、標(biāo)題、窗口背景色等。

  "window": {
    "backgroundTextStyle": "light",
    "navigationBarBackgroundColor": "#fff",
    "navigationBarTitleText": "我是展示標(biāo)題",
    "navigationBarTextStyle": "black"
  },

tarBar如果小程序是一個(gè)多 tab 應(yīng)用(客戶端窗口的底部或頂部有 tab 欄可以切換頁面),可以通過 tabBar 配置項(xiàng)指定 tab 欄的表現(xiàn),以及 tab 切換時(shí)顯示的對應(yīng)頁面。

  "tabBar": {
    "backgroundColor": "#FFFFFF",
    "color": "#181818",
    "selectedColor": "#221415",
    "list": [
      {
        "pagePath": "pages/ar/ar",
        "iconPath": "images/tabbar/arg.png",
        "selectedIconPath": "images/tabbar/AR.png",
        "text": "AR"
      },
      {
        "pagePath": "pages/play/play",
        "iconPath": "images/tabbar/play.png",
        "selectedIconPath": "images/tabbar/playg.png",
        "text": "玩法"
      },
      {
        "pagePath": "pages/index/index",
        "iconPath": "images/tabbar/mine.png",
        "selectedIconPath": "images/tabbar/my.png",
        "text": "我的"
      }
    ]
  },

usingComponents

在 app.json 中聲明的自定義組件視為全局自定義組件,在小程序內(nèi)的頁面或自定義組件中可以直接使用而無需再聲明。建議僅在此聲明幾乎所有頁面都會用到的自定義組件。

注1:全局自定義組件會視為被所有頁面依賴,會在所有頁面啟動時(shí)進(jìn)行初始化,影響啟動性能且會占用主包大小。只被個(gè)別頁面或分包引用的自定義組件應(yīng)盡量在頁面配置中聲明。 注2:在全局聲明使用率低的自定義組件會大幅影響按需注入的效果。

我在這里用的是vant的微信小程序組件庫https://youzan.github.io/vant-weapp/#/home(Vant Weapp)

  "usingComponents": {
    "van-image": "@vant/weapp/image/index",
    "van-field": "@vant/weapp/field/index",
    "van-divider": "@vant/weapp/divider/index",
    "van-button": "@vant/weapp/button/index",
    "van-toast": "@vant/weapp/toast/index"
  },

requiredPrivateInfos

自 2022 年 7 月 14 日后發(fā)布的小程序,使用以下8個(gè)地理位置相關(guān)接口時(shí),需要聲明該字段,否則將無法正常使用。2022 年 7 月 14 日前發(fā)布的小程序不受影響。

申明需要使用的地理位置相關(guān)接口,類型為數(shù)組。目前支持以下項(xiàng)目:

getFuzzyLocation: 獲取模糊地理位置

getLocation: 獲取精確地理位置

onLocationChange: 監(jiān)聽試試地理位置變化事件

startLocationUpdate: 接收位置消息(前臺)

startLocationUpdateBackground: 接收位置消息(前后臺)

chooseLocation: 打開地圖選擇位置

choosePoi: 打開 POI 列表選擇位置

chooseAddress: 獲取用戶地址信息

  "requiredPrivateInfos": [
    "getLocation"
  ],

permission

微信客戶端 7.0.0 及以上版本支持

小程序接口權(quán)限相關(guān)設(shè)置。字段類型為 Object,結(jié)構(gòu)為:

  "requiredPrivateInfos": [
    "getLocation"
  ],

sitemapLocation

指明 sitemap.json 的位置;默認(rèn)為 'sitemap.json' 即在 app.json 同級目錄下名字的 sitemap.json 文件

  "sitemapLocation": "sitemap.json"

總結(jié)

到此這篇關(guān)于微信小程序開發(fā)app.json全局配置實(shí)戰(zhàn)指南的文章就介紹到這了,更多相關(guān)微信小程序app.json全局配置內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論