Small package size exceeds 2M solution of

Applet package is limited to 2M or less, the excess time click on the preview found error:

Error: code package size is 3701 kb, an upper limit of 2048 kb, delete the file and try again

1. optimized code, unused code is removed

2.  Picture compression or upload server

Generally the larger picture space occupied, try not to put small local program folder, if the picture is not much we can also compress the pictures, I often use images compression platform: Click here ;

Pictures can also be uploaded to the server, outside the chain of reference, we are using the oss Ali cloud storage, the other can also be hosted by the picture image hosting platform, I found the image hosting platform: Click here ;

In addition, uni app project created by cli command, you can picture or icon in the font folder under assets, by the introduction of require, can also reduce the size of the main package (This method is applicable to other small framework unknown)

3. Load subcontracting

The official launch of the sub-applet loaded this function, the program for the thousands of small developers, this is big and good news on how subcontracting, micro-channel official document has been explained very clearly, it is recommended to read carefully prior to subcontractors official documents .

Next, a brief introduction to use in a different frame of:

In uni app in:

 uni app cli initialized by a small directory structure as follows:

├── src
    ├── main.js
    ├── App.vue
    ├── pages.json
    ├── manifest.json
    ├── orderPackages
    │   └── pages
    │       ├── goodsDetail
    │       └── myorder
    ├── pages
    │   ├── index
    │   └── user
    └── utils

SubPackages need to configure the field pages.json

{
  "pages": [
    {
      "path": "pages/index/index",
      "style": {
        "navigationBarTitleText": "首页"
      }
    },
    {
      "path": "pages/user/user",
      "style": {
        "navigationBarTitleText": "个人中心"
      }
    }
  ],
  "subPackages": [{
    "root": "orderPackages",
    "pages": [{
        "path": "pages/goodsDetail/goodsDetail",
        "style": {
          "navigationStyle": "custom"
        }
      },
      {
         "Path": "Pages and the / myorder / myorder," ,
         "style" : {
           "navigationBarTitleText": "My orders" 
        } 
      } 
    ] 
  }] 
}

Jump on the page subcontracting Page path:

uni.navigateTo({
     url: `/orderPackages/pages/order/order`
})

In taro in:

Small directory structure taro initialized as follows:

├── src
    ├── app.js
    ├── app.scss
    ├── index.html
    ├── packageA
    │   └── pages
    │       ├── goodsDetail
    │       └── myorder
    ├── pages
    │   ├── index
    │   └── user
    └── utils

SubPackages need to configure the field app.js

config = {
    pages: [
      'pages/index/index',
      'pages/user/user'
    ],
    subPackages: [
      {
        'root': 'packageA',
        'pages': [
          'pages/goodsDetail/goodsDetail',
          'pages/myorder/myorder'
        ]
      }
    ]
  }

Jump on the page subcontracting Page path:

taro.navigateTo({
     url: `/orderPackages/pages/order/order`
})

Only the steps listed above and taro uni app framework sub-loaded, native applet subcontracting method to quickly realize, according to official documents, applets framework are numerous, mostly similar, if there are subsequent use other frameworks for development, will be supplemented .

Guess you like

Origin www.cnblogs.com/puerile/p/11884790.html