About the uni-app WeChat applet listening to the return event in the upper left corner of the top

When returning to the previous level on the project, the data in vuex needs to be cleared, and the use of onBackPress is invalid.

onBackPress(e){
    //判断顶部导航栏左边的返回按钮 (e.from === "backbutton")
    if(e.from === "backbutton"){ 
        store.commit("clearRange");
    }
},

After checking the official documentation, I found that onBackPress is invalid for WeChat applets. 


Then I found another life cycle - onUnload

onUnload() {
    store.commit("clearRange") //清空vuex里某个数据
},

Perfect solution! ! !

Guess you like

Origin blog.csdn.net/m0_55868872/article/details/129983672