通过wx.navigateTo()跳转,回调中可以传递回参数

109 阅读1分钟

image.png 父组件

就在访客申请公司的点击事件中通过wx.navigateTo传递参数回到申请表的页面visitorApplyAdd
 toChooseFn (item) {
      this.companyData=item
        wx.navigateTo({
        url: '/pagesD/visitor/visitorApplyAdd',
        success: function(res) { 
          // 通过eventChannel向被打开页面传送数据
          res.eventChannel.emit('apply',{ data:item })
        }
      })
    }
  }

子组件

通过eventChannel.on来接收传递过来的参数即可获得需要的所有参数来操作数据
  onLoad (option) {  
      let that = this;
      const eventChannel=that.getOpenerEventChannel()
      eventChannel.on('apply',function(data) {
        that.formItem.enterprise_id=data.data.id
        that.formItem.enterprise_name=data.data.name
         that.getFloor()
      }) 
  },