微信小程序传递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,
})
},
上一篇:es6学习笔记--字符串&数值&数组&函数&对象的扩展


下一篇:work,i/o最小线程设置