What do you mean by this.$emit ('input',this.val); in vue?

clipboard.png

because of its high repeatability, it is now packaged into a component, Baidu

Sub-component:

<template>
    <div>
        <div class="group">
            <label>{{title}}</label>
            <input type="text" placeholder="" @input="changeData()" v-model="val">
        </div>
    </div>
</template>

<script>
export default {
    props:["title"],
    data () {
        return {
            val:""
        }
    },
    methods:{
        changeData:function(){
            console.log(111);
            this.$emit("input",this.val);
        }
    }
}
</script>

parent component:

<cmsGroup title="" v-model="username"></cmsGroup>

what does the subcomponent this.$emit ("input",this.val); mean? the official website says: this.$emit (event, value) but my parent component doesn"t use events, and the effect comes out. I don"t understand what the "input"" really is here

.

v-model is a grammatical sugar, which is equal to: value+@input


go to the official website to see v-model , you can see


< children @ input= "oninput" > < / children >
trigger component's input method


see that v-model binds to the input event


vue to listen for input input.
this.$emit (), is a trigger for passing values between parent and child components.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e451fd-65125.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e451fd-65125.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?