Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@yoshinyan

Vue.jsで深い連想配列の値をwatchしたい場合

More than 1 year has passed since last update.

深い連想配列の値をwatchしたい場合は、こうする。


var data = {
    hogedData: {
        fugaData: '', // これの変更をwatchしてイベントを起こしたいとする
        piypData: ''
    }
}

var vue = new Vue({
    data: data,
    watch: {
       hogeData: {
            handler(val) {
                console.log(val); // この辺に、functionを書くとfugaDataの変更を感知して起動できる
            },
            deep:true
   }
})

参考サイト
Vue.js API
https://jp.vuejs.org/v2/api/#vm-options

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
yoshinyan
Webアプリケーションエンジニア。 PHP/Laravel/JavaScript/Vue.js/Ruby/Rails
yyphp
PHPerが毎週集まり、ざっくばらんに情報交換する雑談コミュニティ

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?