1.this.
r
o
u
t
e
r
.
g
o
(
0
)
这
种
方
法
页
面
会
一
瞬
间
的
白
屏
.
2.
l
o
c
a
t
i
o
n
.
r
e
l
o
a
d
(
)
这
种
也
是
一
样
,
画
面
一
闪
.
3.
跳
转
空
白
页
再
跳
回
原
页
面
在
需
要
页
面
刷
新
的
地
方
写
上
:
t
h
i
s
.
router.go(0) 这种方法页面会一瞬间的白屏. 2.location.reload() 这种也是一样,画面一闪. 3.跳转空白页再跳回原页面 在需要页面刷新的地方写上:this.
router.go(0)这种方法页面会一瞬间的白屏.2.location.reload()这种也是一样,画面一闪.3.跳转空白页再跳回原页面在需要页面刷新的地方写上:this.router.push(’/emptyPage’),跳转到一个空白页。在emptyPage.vue里beforeRouteEnter 钩子里控制页面跳转,从而达到刷新的效果
beforeRouteEnter (to, from, next) {
next(vm => {
vm.KaTeX parse error: Expected 'EOF', got '}' at position 33: …om.path) }̲) }。 4.控制<route…nextTick(function () {
this.isRouterAlive = true
})
这种方法从画面上是看不出破绽的。也可以搭配provide、inject使用。例如:
---------网上的帖子。业务需求是home页面刷新,重新渲染数据,如果用方法5的话。刷新会导致,弹窗和menu部分消失。所以不用刷新页面,只重新调用接口。从而实现数据的重新渲染。这个没有实操,现存着,用的时候做参考。
1、给Vue的原型上添加一个bus属性
main.js:Vue.prototype.KaTeX parse error: Expected '}', got 'EOF' at end of input: …ofile () {this.bus.KaTeX parse error: Expected 'EOF', got '}' at position 15: emit('change')}̲ 3、页面1里监听如果执行了操…bus.$on(‘change’, ()=> {
this.doSomething()
})
},