keep-alive判断当前名字和之前的名字是否一样,不一样才请求接口
首先在app.vue里面
<template>
<div >
<keep-alive>
<router-view></router-view>
</keep-alive>
</div>
</template>
<style lang="stylus">
</style>
然后在home.vue里面script里面
data() {
return {
spikeList: [],
likeList: [],
originCity:'' //创建一个空的参数
};
},
created() {}, activated(){ if(this.originCity != this.cityName){ //判断当前的城市名和仓库里面的名字是否一样如果不一样就 this.http() this.originCity = this.cityName } }, mounted() { this.originCity = this.cityName this.http(); }, };

浙公网安备 33010602011771号