天天看點

微信小程式分包加載設定

設定分包加載

  • 主包或者單個分包最大為2M
  • 整體小程式所有包最大為8M

為什麼需要設定分包?

  1. 小程式項目中,有多種角色(公共頁面很少),設定分包加載友善管理
  2. 整個小程式壓縮後代碼大小超過2M,隻能将小程式哈芬為不同的包
  3. 分包加載,在小程式啟動時,預設下載下傳主包并啟動主包内的頁面,當使用者進入某個分包時,将對應的分包下載下傳并啟動,優化小程式首次啟動的下載下傳時間。
"pages": [
    "loading/loading"      //主包
  ],
  "subpackages": [
    {
      "root": "procurement",  //分包名稱
      "pages": [   //分包内的頁面(路徑)
        "index/index",
        "myPassCard/myPassCard",
        "apply/apply",
        "usable/usable",
        "unauthorized/unauthorized",
        "authdriver/authdriver",
        "applicationdetails/applicationdetails",
        "rejectdetail/rejectdetail",
        "createInvitecode/createInvitecode"
      ]
    },
    {
      "root": "driver",
      "pages": [
        "index/index",
        "driverPassCard/driverPassCard",
        "useable/useable",
        "unauthorized/unauthorized",
        "applicationdetails/applicationdetails",
        "rejectdetail/rejectdetail",
        "apply/apply",
        "changeWay/changeWay"
      ]
    },
    {
      "root": "rural",
      "pages": [
        "index/index",
        "ruralPassCard/ruralPassCard",
        "stayconfirm/stayconfirm",
        "useable/useable",
        "changeGoods/changeGoods",
        "loadconfirm/loadconfirm",
        "writeLoadInfo/writeLoadInfo"
      ]
    },
    {
      "root": "station",
      "pages": [
        "index/index",
        "carList/carList",
        "scan/scan",
        "carListDetail/carListDetail"
      ]
    },
    {
      "root": "GaoGuanju",
      "pages": [
        "index/index",
        "myPassCard/myPassCard",
        "useable/useable",
        "audit/audit",
        "rejected/rejected",
        "chart/chart",
        "credit/credit",
        "creditDetail/creditDetail",
        "scan/scan"
      ]
    },
    {
      "root": "pages",
      "pages": [
        "login/login",
        "forgetpassword/forgetpassword",
        "register/register",
        "setting/setting",
        "qrCode/qrCode",
        "message/message",
        "historycredent/historycredent",
        "resetPass/resetPass",
        "search/search",
        "historydetail/historydetail",
        "credentialUsed/credentialUsed",
        "about/about",
        "addGoods/addGoods",
        "deal/deal",
        "messageDetail/messageDetail"
      ]
    }
  ],