URL传参

通过URL进行参数传递,可以实现一个简易的验证流程

1
2
3
4
5
6
7
8
9
10
envJudge () {
let href = location.href.split('?')
if (href.length > 1 && href[1] === 'build') {
console.log('open build')
this.build = true
} else {
console.log('colse build')
this.build = false
}
}

标准格式获取参数用例

1
2
3
4
5
6
7
8
getUid () {
let href = location.href.split('?')
if (href.length > 1) href = href[1].split('&&')
else return
for (let i = 0; i < href.length; i++) {
if (href[i].match('uid')) return href[i].split('=')[1]
}
}