Commit 5dff25e9 by 穆启卓

provide / inject 处理vue重新路由到当前页面

parent e66965e9
<template> <template>
<div id="app"> <div id="app">
<router-view/> <router-view v-if="isRouterAlive"/>
<HelloWorld></HelloWorld> <HelloWorld></HelloWorld>
</div> </div>
</template> </template>
...@@ -10,6 +10,16 @@ ...@@ -10,6 +10,16 @@
components: { components: {
HelloWorld HelloWorld
}, },
provide() {
return {
reload: this.reload
}
},
data() {
return {
isRouterAlive: true
}
},
mounted() { mounted() {
// 是否直接打开报名页 // 是否直接打开报名页
(() => { (() => {
...@@ -54,6 +64,14 @@ ...@@ -54,6 +64,14 @@
false false
); );
})(window); })(window);
},
methods: {
reload() {
this.isRouterAlive = false;
this.$nextTick(() => {
this.isRouterAlive = true;
})
}
} }
}; };
</script> </script>
......
...@@ -154,6 +154,7 @@ export default { ...@@ -154,6 +154,7 @@ export default {
Reborn, Reborn,
ShareModal ShareModal
}, },
inject: ['reload'],
data() { data() {
return { return {
swiperOption: { swiperOption: {
...@@ -232,6 +233,7 @@ export default { ...@@ -232,6 +233,7 @@ export default {
week: this.next_period week: this.next_period
} }
}); });
this.reload();
} else { } else {
this.$router.push({ this.$router.push({
name: "PartakeChallenge", name: "PartakeChallenge",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment