微信小程序传递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?&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, }) },
- 上一篇 »微信小程序开发小结
- 下一篇 »微信小程序开发-微信支付之免密支付,自动扣费 签约授权