index页面中
uni.$once('nextStep', function(e) {
console.log(e); // 接收从detail页面中返回传递出来的参数
// 点击后返回该页面需要做的处理
})
uni.navigateTo({
url: `/pages/index/detail`,
});
跳转后到detail页面后
onUnload() { // 当页面销毁时需要把该方法销毁
uni.$off('nextStep');
},
点击事件中返回需要调用index的nextStep
uni.$emit('nextStep', {
// 可以选择给index页面传递参数
})
uni.navigateBack({
delta: 1
});
文章讲述了在使用Vue.js开发微信小程序时,如何在index页面与detail页面间进行跳转,以及如何在跳转前后处理数据传递和生命周期函数,如`$once`监听和`$emit`触发事件。
7224





