微信小程序传递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,
    })
  },

    

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM