今天项目中有一个这样问题,自己记录一下,
<template>
<div>
</div>
</template>
<script>
export default {
name: 'edit',
props: {},
data() {
return {
}
},
created() {
this.urlFunction('https://blog.csdn.net/qq_28586135/article/details/128547966?spm=1001.2014.3001.5501')
},
methods: {
urlFunction(url){
// 获取本地连接
// var url = window.location.href;
var object = {};
if(url.indexOf("?") != -1) {
var array = url.split("?");
var str = ""
for(var S in array){
str = array[1]
}
var newArray = str.split("&");
for(var i = 0; i < newArray.length; i ++) {
object[newArray[i].split("=")[0]] = unescape(newArray[i].split("=")[1]);
}
}
console.log(object)
}
}
}
</script>