截取路由(链接地址栏)参数
程序员文章站
2024-02-19 18:45:28
...
methods:{
//获取链接参数
getRequest() {
var url = window.location.href;
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.split("?")[1];
var strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
},
//id与name为地址栏参数
//使用id:this.getRequest()['id']
//使用name:this.getRequest()['name']
// 获取图文快讯分页
getGraphicList() {
showLoading();
let {
page,
pageSize
} = this;
getGraphicList({
graphicInformationId: this.getRequest()['id'],//使用id
page,
pageSize
}).then(res => {
hideLoading();
let {
code,
data
} = res;
if (code === 0 && data && data.list && data.list.length) {
this.picWordList = [...this.picWordList, ...data.list];
this.totalPage = data.pagination.totalPage;
this.shareOut();
}
}).catch(() => {})
// },
},
}