uni-app A页面向B页面传递数组

A页面 主要是用encodeURIComponent 编码

const params = this.workPlan.length > 0;
const list = encodeURIComponent(JSON.stringify(this.workPlan));
uni.navigateTo({
    
    
  // url: "/pages/bookAMeeting/configureTheTask",
  url: `${
      
      params ? "/pages/bookAMeeting/configureTheTask?item="+list :"/pages/bookAMeeting/configureTheTask"}`
});

B页面 decodeURIComponent 解码

onLoad: function (option) {
    
    
    const receiveData = JSON.stringify(option)!=='{}' ? JSON.parse(decodeURIComponent(option.item)):[];
        if(receiveData.length>0){
    
    
            this.form = receiveData
        }
}

可以参考官方文档 https://uniapp.dcloud.net.cn/api/router.html#navigateto

猜你喜欢

转载自blog.csdn.net/weixin_44202904/article/details/129561000