Small program development is more and more hot, development encountered a variety of bugs, in this summary of some easier to fall into the pit to share with you.
1. New Date cross-platform compatibility problem
There is no problem with using new Date(” 2018-05-30 00:00:00 “) on Android, but it is not recognized on ios.
Because IOS does not recognize this format, it needs to use 2018/05/30 00:00:00 format. You can use regular expressions to do string substitution to replace the dash with a slash. var iosDate= date.replace(/-/g, ‘/’); .
2. Wx.getuserinfo () interface change problem
One of the most ridiculed recent changes to the wechat mini program is that it will not pop up authorization when users use wx.getUserInfo (development and trial version), and the official version will not be affected. The current authorization method is to guide the user to click an authorization button, and then pop up authorization.
The solution is long, please refer to:
- Wechat applets do not support the wx.getUserInfo authorization solution
- GetUserInfo compatible solution
3. You can send data to your official server only in debug mode
In fact, as long as the attention to configure legitimate domain name, this problem is solved. Sometimes, because the first development, forget to configure the domain name. Later found that the data can not go out, may not want to forget the configuration for a long time!
4. Failed to obtain the UnionID
Login must meet the following two conditions to obtain the UID:
- The small program and public number are bound in the open platform;
- Users must already follow the public account.
Use wx.getUserInfo to get if one condition is met:
- The small program and public number are bound in the open platform;
5. Wx. getSystemInfoSync get windowHeight incorrect
The main reason is that the fetch is timing, wx.getSystemInfoSync is calculated when the page is initialized, basically the height of the screen. Therefore, the best way is to use the asynchronous interface and call it in the onReady function.
onReady() {
wx.getSystemInfo({
success({windowHeight}) {
// todo}}); }Copy the code
6. Name the image local resource in lower case
When addressing iPhone X adaptation, the bottom part of the superfluous use of images
<image class='iphonexImg' src="/imgs/iphoneBGT.png" mode="aspectFill">
Copy the code
Path is SRC = ‘imgs/iphoneBGT. PNG’
It is found that the image can be displayed on the PC IDE, but the picture can not be found when debugging the real machine.
Then change the image name to iphoneX. PNG real machine debugging is ok
<image class='iphonexImg' src="/imgs/iphonex.png" mode="aspectFill">`
Copy the code
Last: Code has bugs, and problems like the ones listed above can be found during development. Once the code goes live, testing is not 100% problem-free. Here, recommend Fundebug micro program BUG monitoring service to you old friends!
About Fundebug
Fundebug focuses on JavaScript, wechat applets, wechat mini games, Alipay applets, React Native, Node.js and Java real-time BUG monitoring. Since its official launch on November 11, 2016, Fundebug has handled more than 700 million error events in total, which has been recognized by many well-known users such as Google, 360, Kingsoft, and People’s Net. Welcome free trial!
Copyright statement
Reprint please indicate the author Fundebug and this article addresses: blog.fundebug.com/2018/10/19/…