使用watch监听路由变化和watch监听对象的实例
一、watch监听路由变化
解决办法:
exportdefault{ data(){ return{} }, watch:{ "$route":"getPath"//监听事件 }, methods:{ getPath(){ letpath=this.$roune.path;//或得当前路径 进行逻辑判断 } } }
二、watch监听对象
例子:
exportdefault{ data(){ return{ form:{ region:"" } } }, watch:{ 'form.region':function(newValue,oldValue){ console.info(newValue); console.info(oldValue); } } }
以上这篇使用watch监听路由变化和watch监听对象的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。