<template>
<div>
<div class="loading-box">
<van-loading size="24px" color="#0094ff">加载中....</van-loading>
</div>
</div>
</template>
<script>
export default {
data() {
return {
fromPage: "",
};
},
created() {
let _this = this;
console.log(_"created",this.fromPage);
},
mounted() {
let _this = this;
console.log(_this.fromPage,"mounted");
if ( _this.fromPage=="/home") {
window.location.href = "https://www.baidu.com"; // 跳转对应地址
} else {
_this.$router.push({name: "HomeIndex"});
}
},
beforeRouteEnter(to, from, next) {
console.log( 'beforeRouteEnter',from);
next(vm => {
// vm相当于上面的this
vm.fromPage = from.path;
});
},
methods: {}
};
</script>
<style lang="less" scoped></style>
转载请注明:有爱前端 » Vue监听路由 从哪个页面跳转过来的 进行后续相关操作