1.首先说明的现象进入详情页返回的时候,红色区块消失,swip组件滑动效果消失
刷新页面纠正了,所以就找刷新页面的方法
1.localtion.reload() 和this.$router.go(0) 页面会出现闪烁
2.新建空白页跳转,然后再重空白页跳转回来 但是又出现问题了
从top页返回不到A页面,top和empty页面出现了死循环,你会问为什么不做个判断让他跳转到A页面呢,首先我们这个是模块打包,A和我现在这个不是一个模块,所以返回到A以后等还是有问题
3.provide / inject组合
APP.vue
<template>
<div id="app">
<keep-alive>
<router-view v-show="$route.meta.keepAlive"/>
</keep-alive>
<router-view v-if="isRouterAlive"/>
</div>
</template>
<script>
export default {
name: 'App',
provide(){
return{
reload:this.reload
}
},
data(){
return{
isRouterAlive:true
}
},
components:{
SHeader,
Tabbar
},
methods: {
reload (){
this.isRouterAlive = false
this.$nextTick(function(){
this.isRouterAlive = true
})
}
}
}
</script>
子组件引用
使用的时候直接调用 this.reload();
哦,myGod 这是vue3版本的使用方法,我们还在使用版本2
继续查找发现向下滑动后,进入详情页返回当前页,下面list展示不完整,灵光一现,是不是scrollTop为0这个问题,然后加上代码
scrollBehavior (to, from, savedPosition) {
return {x:0,y:0}
}
完美搞定