1、manifest.json内添加如图所示:
"optimization" : {
"subPackages" : true
},
2、在与pages同级上创建各个分包的文件夹
把需要分包的文件对应移入分包文件夹内
3、page.json内修改分包文件的路径
比如:文章来源:https://www.toymoban.com/news/detail-644697.html
{
"path" : "pages/vehicle/vehicle",
"style" :
{
"navigationBarTitleText": "我的车辆",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor":"#ffff",
"navigationBarTextStyle":"black"
}
},
"subPackages": [
{
"root": "packageProjectList1",//分包文件夹1名称
"pages": [
{
"path": "vehicle/vehicle",
"style" :
{
"navigationBarTitleText": "我的车辆1",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor":"#ffff",
"navigationBarTextStyle":"black"
}
},
{
"path": "order/order",
"style" :
{
"navigationBarTitleText": "我的订单",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor":"#ffff",
"navigationBarTextStyle":"black"
}
}
]
},
{
"root": "packageProjectList2",//分包文件夹2名称
"pages": [{
"path": "vehicle2/vehicle2",
"style" :
{
"navigationBarTitleText": "我的车辆2",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor":"#ffff",
"navigationBarTextStyle":"black"
}
}]
}
],
3、页面内跳转路径修改
比如:文章来源地址https://www.toymoban.com/news/detail-644697.html
//分包前
toMyCar(){
uni.navigateTo({
url:"/pages/vehicle/vehicle"
})
},
//分包后
toMyCar(){
uni.navigateTo({
url:"/packageProjectList/vehicle/vehicle"
})
},
到了这里,关于uniapp 微信小程序 分包的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!