侦听器

侦听器常用于数据变化时执行异步操作或耗时较长的操作

侦听器的用法:

    var vm = new Vue({
            el: '#app',
            data: {
                fristName: 'xukun',
                lastName: 'cai',
                fullName: 'xukun cai'
            },
            watch: {
                fristName: function(val) {
                    this.fullName = val + ' ' + this.lastName;
                },
                lastName: function(val) {
                    this.fullName = this.fristName + ' ' + val;
                }
            }
        })

  

你可能感兴趣的:(侦听器)