返回上一页this.$router.go(-1)
刷新页面location.reload()
补充:只刷新一次
if (location.href.indexOf("#reloaded") == -1) {
location.href = location.href + "#reloaded";
location.reload();
}
一、同域传递参数
//@跳转路由传参@
//传单个值
this.$router.push({
path: `/describe/${id}`,
})
//传对象或数组{ }
this.$router.push({
name: `describe`,
query:{ id: 1 }
})
//接受对象或数组
let data = this.$route.query
//打开新标签传值
let routeData = this.$router.resolve({
name: 'accountApply',
query: { id: 1 }
});
window.open(routeData.href, '_blank');
二、跳转外部链接
var url = 'www.baidu.com'
//跳转1
window.location.href = url
//跳转2
window.history.pushState(url);
window.history.replaceState(url);
//跳转3
window.open(url, "_blank");
//跳转4
var a = document.createElement("a");
a.setAttribute("href", "www.baidu.com");
a.setAttribute("target", "_blank");
a.click();
三、监听路由参数变化
data(){
return{
id:""
}
},
watch: {
//参数发生改变,直接调用 changeId 方法
$route:'changeId'
},
methods: {
//调用次方法
changeId(){
this.id = this.$route.query.id
}
}
个人记录,不喜勿喷
网友评论