uni.navigateBack()返回上一级并传参,上一级页面onShow()函数中接参
<template>
<view></view>
</template>
<script>
export default {
data() {
return {
}
},
onShow() {
let that = this
uni.$on('returnData',function(data){
console.log('监听到事件来自返回的参数:' + data);
})
},
methods: {
}
}
</script>
<style>
</style>
<template>
<view>
<button @click="goBack">点击返回上一页</button>
</view>
</template>
<script>
export default {
data() {
return {
index:1,
}
},
methods: {
goBack() {
uni.$emit('returnData', this.index)
uni.navigateBack({
delta: 1
})
}
}
}
</script>
<style>
</style>