下面这个是一串正常的url
https://editor.csdn.net/md?not_checkout=10&spm=1001.201001.9739&articleId=27834274872
转码过的字符串
https://editor.csdn.net/md?not_checkout=1%26spm=1001.2014.3001.9739%26articleid=132576228
上面这个代码如何再转回去
js通过decodeURIComponent
方法可以转回原来的样式
然后就获取到了
然后你还想继续骚操作,拿到下面的数据
const scene_decode = (e) => {
if (e === undefined) return {}
let scene = decodeURIComponent(e)
let params = scene.split('?')[1].split('&')
let data = {}
for (let i in params) {
var val = params[i].split('=')
val.length > 0 && val[0] && (data[val[0]] = val[1] || null)
}
return data
}