實時監聽組件中路由的變化


實時監聽組件中路由的變化,通過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