Records of pitfalls in small program development

Welcome everyone to add

1. Time

Question: Judging whether the time exceeds today, new Date('2022-06-10') < new Date(), the simulator is correct, but it is actually false on iOS.

Reason: The date format year-month-day is not compatible with ios, you must first convert the date to year/month/day

Solution: '2022-06-10 '.replaceAll('-', '/')

2.disableTouch

Question: When writing a pop-up window, do not add disableTouch to the pop-up window, the area under the pop-up window can slide, but add disableTouch, if there is a sliding part in the pop-up window, it will not slide

Reason: disableTouch prohibits all sliding events in the entire disabledTouch area

Solution: 1" After adding disableTouch, use scroll-view where you need to slide

                  2" Dynamically set the value of disableTouch

3.flex layout

Flex layout sets the spacing between child elements, using gap, column-gap, row-gap; Android phones are not compatible

4. \n newline does not work

Add white-space: pre-line; in css

5.requestSubscribeMessage

wx.requestSubscribeMessage() is executed, no error is reported, no box pops up, because the box is checked and no longer asked, no popup window will appear

6. InnerAudioContext.onTimeUpdate is not triggered when called again (WeChat applet bug)

Cause: onUpdateTime fails due to audio loading (for example, when calling seek, the audio is automatically loaded)

Summary: Since onUpdateTime can take effect by using innerAudioContext.paused (for example: printing), you only need to judge under what circumstances to use innerAudioContext.paused. Since onCanPlay will be triggered every time the audio is loaded, add it to this callback.

Solution: innerAudioContext.onCanPlay(()=>{ console.log(innerAudioContext.paused) })

Others: The upstairs said that adding setTimeout(() => { console.log(innerAudioContext.paused) },100) after the seek can also solve the problem. Since the audio loading time after the seek is not fixed, if the audio is not loaded within 100 milliseconds, Still can't trigger onUpdateTime, so adding it to onCanPlay is more accurate.

Guess you like

Origin blog.csdn.net/animatecat/article/details/125527844