watch: {
$route(to) {
console.log(to)
if (to.path.indexOf('index') != -1) { //路由变化后重新获取帖子列表 this.$http.get('/api/communityList').then((res) => { if (res.data.errCode === 0) { let getRes = res.data.data.hotList this.postList = getRes } }) } } }
vue使用watch 观察路由变化,重新获取内容
猜你喜欢
转载自www.cnblogs.com/aacoutlook/p/9037422.html
今日推荐
周排行