The problems, solutions, and specific development process encountered during the development of the picture modification assistant applet
Applet development process
Demand confirmation
When confirming the demand, pay attention to some restrictions of WeChat. Here are the points I encountered.
The total size of the bag does not exceed 1m
The total number of pages does not exceed 5
There are different api effects between the editor and the real machine (for example: the canvasToTempFilePath editor cannot be executed)
Only after adding the appid can there be preview function and real machine debugging . However, at this time, all requests must be configured third-party servers .
Front scaffolding determined
Reasons for choosing scaffolding
WeChat applet comes with an editor (the hot update configuration file is not supported, comments are not supported, no code compression ... etc.)
Introduction to Scaffolding
Integrated
Redux
, data management is more convenientDuring the development process, the use of
xml
replacement iswxml
more friendly to development toolsIn the development process, use
less
replacewxss
, more powerfulIntroduced
es-promise
so that it can be created and usedPromise
Add
promisify
tool function, you can easily convert the officialApi
into aPormise
modelIntroduced to
normalizr
flatten data and make data management more convenientIntroduce
babel
automaticES2015
feature conversionThe compression of wxml / wxss / js / img will reduce the loss volume compared to the compression provided by the developer tools.
It is recommended to learn redux
All states are stored in a single store in the form of an object tree
The only changeable state is the action, which describes what happened.
Describe how actions change state. Write reducers
You should turn the changes you want to make into a normal object. This object is called an action instead of directly modifying the state. Then write a special function to determine how each action changes the state of the application. This function is called a reducer.
Develop applet
The official document can be found on: https: //mp.weixin.qq.com/debu ...
Problem log
Mobile adaptation issues
Using the small program rpx unit directly according to the design drawing can be equivalent to the upgraded version of rem
Theme color title bar color configuration
Can be configured in app.json
Canvas drawing cannot use network resources and base64, only local files
Use the built-in api to store local temporary files for production rendering
Style switch
1) You can directly bind a variable class or style 2) Use wx: if wx: else
Some build folders are missing
Pay attention to whether there is an error in the compilation information
Put it on the local server and use the applet to open the flashback
At present, the reason can only be placed locally
This article is reproduced in: Ape 2048 → https://www.mk2048.com/blog/blog.php?id=h00c2c2cb0j