触发监听执行多个方法

【触发监听执行多个方法】当我们触发监听执行多个方法时,使用数组可以设置多项,形式包括字符串、函数、对象

export default { data: { name: 'jane' }, watch: { name: [ 'sayName1', function(newVal, oldVal) { this.sayName2() }, { handler: 'sayName3', immaediate: true } ] }, methods: { sayName1() { console.log('sayName1==>', this.name) }, sayName2() { console.log('sayName2==>', this.name) }, sayName3() { console.log('sayName3==>', this.name) } } }

    推荐阅读