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


实时监听组件中路由的变化,通过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)
})
}
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM