VUE如何同时监听多个变量的变化

使用computed配合watch监听变量变化

data() {
    
    
	return {
    
    
		username:'',
		password:''
	}
},
computed: {
    
    
  changeData() {
    
    
    const {
    
     username, password} = this
    return {
    
    
      username,
      password
    }
  }
}, 
watch: {
    
    
 	changeData(e) {
    
    
  	//写入你需要监听的事件
	}
    
},

Guess you like

Origin blog.csdn.net/pgzero/article/details/106558049