[] Watch Vue monitor

Monitor, you can monitor data changes can also monitor changes in the route, shown here change the value of listening, listening change the route of delivery as otherwise described in the article routing parameters.

This article shows that the text box, and display the old and new value of listeners:

Code

<template>
<div>
  <input v-model="data">{{data2}}
</div>
</template>

<script>
    export default {
        name: "Vue01",
        data(){
            return{
                data:'',
                data2:''
            }
        },
        watch:{
            data(newValue,oldValue){//名称与要监听的数据一致即可
                this.data2=oldValue+'--->'+newValue;
            }
        }
    }
</script>

<style scoped>

</style>

 

Published 47 original articles · won praise 4 · Views 7483

Guess you like

Origin blog.csdn.net/weixin_39370093/article/details/99701642
Recommended