Skip to content
Advertisement

how can i watcha multidimensional key in Vuejs

I’m working on a small project, and I would like to know how can i watch my search key

this is my code :

data:() => ({
     form: {
        search: '',
     }
}),
watch: {
    // how can i watch search
}

Advertisement

Answer

data: () => ({
    form: {
        search: '',
    }
}),
watch: {
    'form.search': (new, old) => {
        // do something
    }
}

full example on vue doc

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement