Examples of objects dom transfer method vue

<div id="app">
    <input type="text" v-on:keyup="onlyNum($event)">
</div>

<script>
new Vue({
    el:"#app",
    methods: {
        onlyNum: function (event){
            event.target.value=event.target.value.replace(/[^\d]/g,'');
        }
    }
})
</script>

 It is equivalent to:

<div id="app">
    <input type="text" onkeyup="onlyNum(this)">
</div>

<script>
        function onlyNum(obj){
            obj.value = obj.value.replace(/[^\d]/g,'');
        }
</script>

 js native code of "this" is equivalent to the vue "event.target".

Guess you like

Origin www.cnblogs.com/qingsong/p/11575485.html