点我去Gitee
点我去Gitee

url传递参数 加码和解码 encodeURI decodeURI

url传递参数 url的加码和解码 encodeURI decodeURI

加码 encodeURI

const sendData = {
      boxId: this.state.boxIdMessage[0].boxId,
      flag: "add",
      from: 'boxMessage'
    }
    let jsonsendDataTemp = JSON.stringify(sendData)
    let jsonsendData = encodeURI(jsonsendDataTemp)
    // 【3首=》扫=》盒=》编(从盒子到编辑) 3.盒子页创建编辑页(添加)】
    if (_openw) { return }  // 防止快速点击
    _openw = createWebview('http://cncwww.cn:9000/#/edictor?sendData=' + jsonsendData, 'edictor_box_add','添加数据')

解码 decodeURI

// 获取路由传过来的值
    let querytemp = this.props.location.search
    let query = decodeURI(querytemp)
    let reciveDataTemp = query.substring(query.indexOf('=') + 1, query.length)
    let reciveData = JSON.parse(reciveDataTemp)
posted @ 2021-10-16 15:50  biuo  阅读(275)  评论(0编辑  收藏  举报