mpvue传参遇到特殊符号“&”后面的内容都传不过来的解决方法

独自空忆成欢 提交于 2020-01-15 16:35:21

1.在全局引用

import {
  getQuery,
  toParams
} from '@/libs/utils'
Vue.prototype.query = getQuery
Vue.prototype.params = toParams

2.通过地址传参,首先构造要传的内容

  goTest (item) {
      const query = {
        describe: item.describe,
        id: item.id
      }
      wx.navigateTo({
        url: `/pages/test?${this.params(query)}`
      })
    },

3.在获得页面接收数据,即可把一些特殊的符号都能显示啦

 onLoad(options) {
    var that = this
    let { describe } = this.query()
    describe = decodeURIComponent(describe)

    this.title = describe
    this.id = options.id
  }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!