vue watch监控的高级用法

558 阅读1分钟

watch: {
    'form.name' (nv, ov) {
        if (nv) {
            console.log(nv)
        }
     }
} // 注意这只是普通用法,稍微复杂点,你根本监控不到

deep深度监控

watch: {
    'form.name': {
        handler (nv, ov) {
            console.log(nv)
        },
        deep: true
    }
} // 基本上可以解决所有监控问题

immediate(触发便会回调)


watch: {
    'form.name': {
        handler (nv, ov) {
            console.log(nv)
        },
        immediate: true
    }
} // 触发便会回调