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! ! !