小程序传递URL中含有特殊字符"="时,解决办法: 先encodeURIComponent,取到值以后再decodeURIComponent 首先在A页面 var urls = encodeURIComponent(e.currentTarget.dataset.teaexamid); var teacherExamName = e.currentT
小程序传递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, }) },