vue 返回上一页传参_Vue 返回上一页,记住上一页的数据

==============搜索页面路由设置===================================

{

// 搜索

path: 'search',

name: 'search',

component: Search,

meta:{

keepAlive: true,

isUseCache:false

}

}

========商品详情页JS=========================================

export default {

beforeRouteLeave (to, from, next) {

//跳转到搜索页面时,search为搜索页面名称

if (to.name == 'search') {

to.meta.isUseCache = true;

}

next();

},

}

========搜索页面===========================================

@click="goToDetail(good.seriesId)"//跳转到详情页面

:price="good.price"

:desc="`${good.kwname} ${good.pricetag}`"

:title="good.seriesname"

:thumb ="good.seriesimg"

class="goods-card" />

export default {

data(){

return{

GoodTitle:"",

good:[]

}

},

activated() {

// isUseCache为false时才重新刷新获取数据

// 因为对goods使用keep-alive来缓存组件,所以默认是会使用缓存数据的

if(!this.$route.meta.isUseCache){//false

this.goods = []; // 清空原有数据

this.GoodsTitle = "";

this.onLoad(); // 这是我们获取数据的函数

this.$route.meta.isUseCache = false;

} else {

this.$route.meta.isUseCache = false;

}

},

methods:{

//获取商品详情

goToDetail(sid) {

//alert("aaa");

this.$router.push({

name: "goodsDetail",

params: {

id: sid

}

});

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值