思路:在uniapp中對微信小程序進行分包,和原生微信小程序進行分包的操作基本上沒區別,主要就是在pages.json中進行配置。
如圖,我新增了一個包diver-page
此時需要在pages.json中的subPackages數組中新增一項
root代表這個包的根路徑
pages代表這個包中所有的頁面
{"root": "page-diver","pages": [{"path": "diver/index/index","style": {"navigationBarTitleText": "","enablePullDownRefresh": false,"navigationStyle": "custom"}},{"path": "diver/tabBar/tabBar","style": {"navigationBarTitleText": "首頁","enablePullDownRefresh": false,"navigationStyle": "custom"}}]},
使用這個包中的頁面時需要帶上根路徑的前綴,如進行tabbar頁面的跳轉
uni.reLaunch({url: "/page-diver/diver/tabBar/tabBar"})