zl程序教程

您现在的位置是:首页 >  APP

当前栏目

微信小程序 从后台接口接收数据并把数据传给要跳转的页面–小程序中页面传值数据不完整(mpvue)

2023-03-07 09:49:24 时间

/******提取链接内容********/

async tq(){

  if(this.data.video_url==”){

    wx.showToast({

      title: ‘请先输入视频链接’,

      icon: ‘none’,

    })

    return 1;

  }

  //解析视频链接

  var res=await app.wx_tb_request(app.domain+’/api/index/cat_qsy’,’post’);

  if(res.code!=1){

    wx.showToast({

      title: ‘解析失败’,

      icon: ‘none’,

    })

    return 1;

  }

  let video_data=JSON.stringify(res.data);//将数据对象转为字符串

  wx.navigateTo({//这种跳转,

    url: ‘/pages/tq/index?video_data=’+ encodeURIComponent(video_data)

  })

},

接收的页面

onLoad(options) {

    // let video_data = JSON.parse(options.video_data); //将字符串转为数据对象

    console.log(decodeURIComponent(options.video_data))

  },

此时可以传过去了,但会有个新问题,就是参数传递不完整,别截断了

解决办法:

解决办法:在传递过去的页面使用encodeURIComponent()方法进行转换。

再在接收的页面中使用decodeURIComponent()方法进行接收。

这样数据就会全部传递过去了。

未经允许不得转载:肥猫博客 » 微信小程序 从后台接口接收数据并把数据传给要跳转的页面–小程序中页面传值数据不完整(mpvue)