1.停留在当前页码
在项目的入口文件(我这里是App.vue)添加<keep-alive></keep-alive>标签开启缓存,
代码如下:
<template>
<div id="app">
<transition name="fade">
<keep-alive>
<router-view v-if="isRouterAlive"></router-view>
</keep-alive>
</transition>
</div>
</template>
2.刷新数据
将回调函数放到activated周期函数内,返回列表页时会触发activated的方法,代码如下:
activated() {
this.getDataList();
},