「Vue」watch基本用法
应用于监视路由地址改变,如有新地址(即路由地址改变)即执行自定义方法
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
methods: { itemShow() { this.$axios.get('item/item/'+this.id+'?token='+this.$store.state.token).then(ret => { console.log(ret) }) }, }, watch: { '$route.path'(newVal,oldVal) { if (newVal) { this.itemShow() } } },