Vue_使用watch監聽對象的三種方法


            data: {
                datas: {
                    a: 77,
                    b: 86
                }
            }

使用deep:true深層次監聽

                'datas':{
                    handler:function(newVal){
                        console.log(this.datas);
                    },
                    deep:true
                }

監聽某一個具體的屬性

                'datas.a':{
                    handler:function(newVal){
                        console.log(this.datas);
                    }
                }

使用computed來監聽某一個具體的屬性

            watch: {
                a(newVal){
                    console.log(this.datas);
                }
            },
            computed: {
                a:function(){
                    return this.datas.a;
                }
            }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM