1. 程式人生 > >小程式分包功能

小程式分包功能

分包其實很簡單,一開始我把他想的很複雜,導致我浪費了半天時間......

其實分包實質上就是目錄結構改變下,然後app.json的配置改變下,

tabbar頁面單獨放一個包,結構如下

{ "pages": [ //pages不能沒有(如果報錯請把註釋刪掉) "page/tabBar/index/index", "page/tabBar/warehouse/index", "page/tabBar/mycenter/index" ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor"
: "#fff", "navigationBarTitleText": "分包演示", "navigationBarTextStyle": "black" }, "tabBar": { "color": "#2e2e2e", "selectedColor": "#db4b29", "backgroundColor": "#FFFFFF", "borderStyle": "#D0D1D3", "fontSize": "22rpx", "list": [ { "pagePath": "page/tabBar/xxx/xxx", "text"
: "首頁", "iconPath": "./res/home.png", "selectedIconPath": "./res/a_home.png" }, { "pagePath": "page/tabBar/xxx/xxx", "text": "茶倉", "iconPath": "./res/cy.png", "selectedIconPath": "./res/a_cy.png" }, { "pagePath": "page/tabBar/xxx/xxx", "text"
: "我的", "iconPath": "./res/my.png", "selectedIconPath": "./res/a_my.png" } ] }, "subPackages": [ { "root": "page/teaindex/", "pages": [ "pages/xxx/xxx" ] }, { "root": "page/warehouse/", "pages": [ "pages/xxx/xxx", ] }, { "root": "page/center/", "pages": [ "pages/xxx/xxx" ] } ]}

分包的好處有很多,無論是載入速度還是體積大小都有不小的提升!'有什麼疑問可以在評論區留言,