码迷,mamicode.com
首页 > 其他好文 > 详细

实时监听组件中路由的变化

时间:2017-12-09 15:55:50      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:route   false   赋值   lis   数据   out   arch   data   query   

实时监听组件中路由的变化,通过watch来进行监听,当路由发生变化时,重新赋值,重新执行从后台获取数据的操作

watch: {
‘$route‘ (to, from) {
this.listQuery.keywords=this.$route.query.keywords
this.searchByKeywords()
}
},
methods: {
searchByKeywords() {
this.$store.dispatch(‘updateLoading‘, true)
fetchSearchByKeywords(this.listQuery)
.then(response => {
this.$store.dispatch(‘updateLoading‘, false)
this.listTotal = response.data.total
this.listData = response.data.data
})
.catch(error => {
console.log(error)
})
}
}

实时监听组件中路由的变化

标签:route   false   赋值   lis   数据   out   arch   data   query   

原文地址:http://www.cnblogs.com/wszxx/p/8011498.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!