方法一:对主包进行分包处理,将使用url: `/pages/components/equipment/equipment`跳转页面的全部拆分为分包,如url: `/pagesS/components/equipment/equipment `
在pages.json中添加
"subPackages": [{
"root": "pagesS/components/",
{
"path": "equipment/equipment",
"style": {
"navigationBarTitleText": "设备的处理"
}
}
]
并且要创建一个新的文件路径为/pagesS/components/equipment/equipmen,将之前的/pages/components/equipment/equipment文件的内容移动到新的文件中,将之前老的文件删除,并且在pages.json中删除老的文件路径
方法二:如果分包之后代码体积还是很大要通过查看代码依赖分析去查看具体哪些代码出现问题
到微信开发者工具中使用预览



就可以看到具体哪个文件的代码内存多,并针对相关问题去解决
解决后

可以明显看出代码依赖已经减少
方法三:在HBuilderX编写的代码转为微信小程序时可以在运行时压缩代码
