1.假设一个对象dataObj
<script>
export default {
data() {
return {
parmsdata: []
}
},
methods:{
//点击事件触发
toRputer(){
let that = this
let dataObj = {
key:"123",
shopid:"18",
studyid:"12
}
//遍历可以采用其他方法,我这里用的是 for ... in
for(let i in dataObj){
that.parmsdata.push('&' + i + '=' + dataObj[i])
console.log(that.parmsdata.join(',').replace(/,/g, ""))//将数组转换成字符串并且去掉所有逗号 用法(this.$router.push("/home?token=13142"+that.parmsdata.join(',').replace(/,/g, "")))
}
}
}
}
</script>