给某个url后面设置参数
this.$router.push({
path:this.$route.path,
query:{...this.$route.query, typeeval:'hadeval'}
})
如果要修改url里面的的某个参数的值,可以使用这个方法:
this.$router.push({
path:this.$route.path,
query:{ typeeval:'noeval' }
})
或者使用以下办法:
// 替换指定传入参数的值,oldName为参数,newWith为新值
function replaceParamVal(oldName,newWith) {
var oUrl = this.location.href.toString();
var re=eval('/('+ oldName+'=)([^&]*)/gi');
var nUrl = oUrl.replace(re,oldName+'='+newWith);
this.location = nUrl;
window.location.href=nUrl
}
在el-tab切换的时候,如果想要刷新的时候页面保持在当前tab,那就可以设置url参数。