Open the page:

navigateNext(e){
    let _this = this;
    wx.navigateTo({
      url: '/pages/main/navigateTo1/navigateTo1? id=1'.events: {
        acceptDataFromOpenedPage: function(data) {// Get data from the opened page to the current page
          console.log("acceptDataFromOpenedPage",data)
          _this.setData({value:data.data});
        },
        someEvent: function(data) {// Get data from the opened page to the current page
          console.log("someEvent",data)
        }
      },
      success: function(res) {
        // Send data to the opened page via eventChannel
        res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test'})}})}Copy the code

Opened page:

Page({
  onLoad: function(option){
    console.log(option.id)
    const eventChannel = this.getOpenerEventChannel()
    eventChannel.emit('acceptDataFromOpenedPage', {data: 'test'});// Pass data to the open page
    eventChannel.emit('someEvent', {data: 'test'});// Pass data to the open page
    
    // Listen for acceptDataFromOpenerPage events to get data sent from the previous page to the current page via eventChannel
    eventChannel.on('acceptDataFromOpenerPage'.function(data) {// Get the data for the open page
      console.log(data)
    })
  }
})
Copy the code