mounted() {
//http://localhost:8080/#/order/Payresult?orderCode=20200721093517378188743943022
var url = window.location.href ; //获取url中"?"符后的字串
var cs = url.split('?')[1]; //获取?之后的参数字符串
//alert(url+'地址');//orderCode=20200721093517378188743943022
var cc ='';
var cs2 = '';
if (cs.length > 0)
{
cs = cs.replace('orderId=', '');
var cc =cs.split('&')[0];//获取orderid
var cs1 = cs.split('&')[1];//ocd=20200818103843816416953617735
var cs2 = cs1.replace('ocd=', '');//20200818103843816416953617735
}
this.oid = cc;
this.orderCode = cs2;
}
====一劳永逸的方法===================
getUrlKey(name){//获取url 参数
return decodeURIComponent(
(new RegExp('[?|&]'+name+'='+'([^&;]+?)(&|#|;|$)').exec(location.href)||[,""])[1].replace(/\+/g,'%20'))||null;
}
引用:
this.getUrlKey(ptype)