vue-test ------事件监听

<template>
<h3>监听器</h3>
  <p>{{message}}</p>
  <button @click="updateHandle">点击</button>
</template>

<script>
export default {
  name: "WatchDemo",
  data(){
    return{
      message:"hello"
    }
  },
  methods:{
    updateHandle(){
      this.message="no hello"
    }
  },
  watch:{
    message(newValue,oldValue){
      console.log(newValue,oldValue)
    }
  }
}
</script>

<style scoped>


</style>
posted @ 2023-11-07 22:56  会秃头的小白  阅读(7)  评论(0编辑  收藏  举报