最近搜索

小程序 分包 分页面 提高加载速度 提高速度

浏览:2
管理员 2026-10-20 10:31






修改app.json

{
  "pages": [

 
    "pages/index/index",

    "pages/profile/profile",
    "pages/vip/vip",
    "pages/type/type",
    "pages/goods_view/goods_view",
    "pages/goods_list/goods_list",
    "pages/profile_edit/profile_edit"

  ],
"subPackages": [
  {
    "root": "subpackage-gys",
    "pages": [
      "apply/apply",
      "bill/bill",
      "goods_fang_manage/goods_fang_manage"
    ]

  }
],

  "window": {
    "navigationBarTextStyle": "black",
    "navigationBarTitleText": "",
    "navigationBarBackgroundColor": "#ffffff"
  },
  "tabBar": {
    "selectedColor": "#1296db",
    "list": [
      {
        "pagePath": "pages/index/index",
        "text": "首页",
        "iconPath": "assets/icon/index.png",
        "selectedIconPath": "assets/icon/index2.png"
      },
      {
        "pagePath": "pages/type/type",
        "text": "找地方",
        "iconPath": "assets/icon/type.png",
        "selectedIconPath": "assets/icon/type2.png"
      },
      {
        "pagePath": "pages/profile/profile",
        "text": "我",
        "iconPath": "assets/icon/person.png",
        "selectedIconPath": "assets/icon/person2.png"
      }
    ]
  },
  "style": "v2",
  "componentFramework": "glass-easel",
  "sitemapLocation": "sitemap.json",
  "lazyCodeLoading": "requiredComponents",
  "requiredPrivateInfos": [
    "getFuzzyLocation"
  ],
  "permission": {
    "scope.userFuzzyLocation": {
      "desc": "你的位置信息将用于,订单创建"
    }
  }
}


分包跳转和普通一样的,js代码复制都可以用。

url和上面都一样


wx.navigateTo({
    url: "/subpackage-gys/apply/apply"
  })




分包可以分多个。

image.png

{
  "pages": [
    "pages/index/index",
    "pages/type/type",
    "pages/profile/profile"
  ],
  "subPackages": [
    {
      "root": "subpackage-order",
      "pages": [
        "apply/apply",
        "bill/bill",
        "order_edit/order_edit",
        "order_edit_list/order_edit_list",
        "order_list/order_list",
        "order_list_linjin/order_list_linjin",
        "order_list_wu_tui/order_list_wu_tui",
        "order_list_tui_id/order_list_tui_id",
        "order_view/order_view",
        "order_list_manage/order_list_manage",
        "order_scan_list/order_scan_list",
        "order_scan/order_scan",
        "goods_order_create/goods_order_create"
      ]
    },
    {
      "root": "subpackage-goods",
      "pages": [
        "vip/vip",
        "goods_add_update/goods_add_update",
        "goods_fang_manage/goods_fang_manage",
        "taocan_manage/taocan_manage",
        "goods_price_guize_jinzhi_add_update/goods_price_guize_jinzhi_add_update",
        "goods_price_guize_add_update/goods_price_guize_add_update",
        "goods_manage/goods_manage",
        "taocan_add_update/taocan_add_update",
        "goods_search/goods_search",
        "goods_type1_list/goods_type1_list",
        "goods_type_list/goods_type_list",
        "goods_view/goods_view",
        "goods_list/goods_list"
      ]
    },
    {
      "root": "subpackage-client",
      "pages": [
        "goods_search_client/goods_search_client",
        "goods_order_create_client/goods_order_create_client",
        "goods_list_recommend/goods_list_recommend"
      ]
    },
    {
      "root": "subpackage-blog",
      "pages": [
        "subscribe_msg_list/subscribe_msg_list",
        "blog_view/blog_view",
        "blog_type_list/blog_type_list",
        "profile_edit/profile_edit"
      ]
    }
  ],
  "window": {
    "navigationBarTextStyle": "black",
    "navigationBarTitleText": "",
    "navigationBarBackgroundColor": "#ffffff"
  },
  "tabBar": {
    "selectedColor": "#1296db",
    "list": [
      {
        "pagePath": "pages/index/index",
        "text": "首页",
        "iconPath": "assets/icon/index.png",
        "selectedIconPath": "assets/icon/index2.png"
      },
      {
        "pagePath": "pages/type/type",
        "text": "找地方",
        "iconPath": "assets/icon/type.png",
        "selectedIconPath": "assets/icon/type2.png"
      },
      {
        "pagePath": "pages/profile/profile",
        "text": "我",
        "iconPath": "assets/icon/person.png",
        "selectedIconPath": "assets/icon/person2.png"
      }
    ]
  },
  "style": "v2",
  "componentFramework": "glass-easel",
  "sitemapLocation": "sitemap.json",
  "lazyCodeLoading": "requiredComponents",
  "requiredPrivateInfos": [
    "getFuzzyLocation"
  ],
  "permission": {
    "scope.userFuzzyLocation": {
      "desc": "你的位置信息将用于,订单创建"
    }
  }
}


联系站长

站长微信:xiaomao0055

站长QQ:14496453