微信小程序傳遞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