mounted() {
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL); //这里有没有都无所谓,最好是有以防万一
window.addEventListener("popstate", this.goBack, false); // 回退时执行goback方法
}
},
methods:{
goBack() {
this.$router.push({ name: 'floor', params: { BName: this.header.buildName})
// 接收参数用this.$route.params.BName
},
}
如果要添加判断某个页面才执行
这里的build是根据你路由配置的当前页面
goBack() {
if(this.$route.path = 'build')
this.$router.push({ name: 'floor', params: { BName: this.header.buildName})
// 接收参数用this.$route.params.BName
},