编程语言
首页 > 编程语言> > 微信小程序传递URL中含有特殊字符

微信小程序传递URL中含有特殊字符

作者:互联网

小程序传递URL中含有特殊字符"="时,解决办法:先encodeURIComponent,取到值以后再decodeURIComponent

  

首先在A页面
var urls = encodeURIComponent(e.currentTarget.dataset.teaexamid);
    var teacherExamName = e.currentTarget.dataset.workname;
    console.log('当前点击的ID', teacherExamName);
    wx.navigateTo({
      url: '/pages/teaTestWork/teaTestWork?id=' + urls + '&examName=' + teacherExamName + '&currId=' + currId,
    })

在B页面,拿到A页面URL中的参数
onLoad: function (options) {
    //先encodeURIComponent,取到值以后再decodeURIComponent
    // console.log(decodeURIComponent(options.id));
    console.log(options);
    this.getExamDetail(decodeURIComponent(options.id));
    this.setData({
      workExamName: options.examName,
      workIds: options.currId,
    })
  },

    

 

标签:console,log,URL,微信,id,decodeURIComponent,teacherExamName,options,特殊字符
来源: https://www.cnblogs.com/lvxisha/p/11651911.html