WeChat Mini Program Development Mining Pit Record

WeChat Mini Program Development Mining Pit Record

1. The WeChat applet reports an error: the XX event is not defined in the page or the page path is not added in the app.json

报错下图所示:
Write picture description here
Do not have onCollectionTap handler in current page: pages/index/index-detail/index-detail. Please make sure that onCollectionTap handler has been defined in pages/index/index-detail/index-detail, or pages/index/index-detail/index-detail has been added into app.json

Prerequisite : Before the problem occurred, the onCollectionTap event has been defined in the index-detail.js file, and the index-detail path has also been configured in app.json, but why this warning is still reported and cannot be triggered event?

problem analysis:

1. First, eliminate the two problems explained above. It is not that the event is not defined and the path of the page is not configured in app.json (pass)

2. Check whether the event defined in js is consistent with the event name in the wxml page (pass)

3. Check what is the difference between the event handler and the event handler that can be triggered?

The problem was found during the inspection. catchtap="onCollectionTap "Pay attention, there is an extra space after the onCollectionTap event name. Is this the problem? Remove the space and trigger the event again. It really is the problem. I don’t know when the hand owes, so I added more. A blank space caused the problem to be solved for more than 10 minutes. In fact, we can all avoid this problem. I hope you all remember, this is the lesson!

Guess you like

Origin blog.csdn.net/it_cgq/article/details/80293455
Recommended