The problem of passing values in vue

< body >

    <div id="app">
        

:{{total}}

<my-component v-model="total"> </my-component> <button @click="handleGetTotal"></button> </div> </body> <script src="https://unpkg.com/vue/dist/vue.min.js"></script> <script> Vue.component("my-component",{ prors:["value"], template:"<input :value="value" @input="handleIncrease"/>", methods:{ handleIncrease:function(event){ this.$emit("input",event.target.value); }, } }); var app=new Vue({ el:"-sharpapp", data:{ total:0 }, methods:{ handleGetTotal:function(){ this.total--; } } }) </script>

Intermediate template:" < input: value= "value" @ input= "handleIncrease" / >", what does this sentence mean? how did this value come from? the browser reported an error saying that value is not defined

.
Apr.12,2021

clipboard.png
I guess you want to write a props


< input: value= "value" @ input= "handleIncrease" / >

: value means to bind the value in props to our usual

.

< input VMI model = "value" @ input= "handleIncrease" / > same

as for @ input= "handleIncrease" , when the value of input changes, the this.$emit ('input') in handleIncrease changes the value of props so that there is a two-way binding effect


v-model is just a syntax sugar. By default, value is passed into the component as an attribute, and then the value value is thrown through the event of input to achieve two-way binding.


have you defined value in data () {return {}}

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-1e44e0f-44b0a.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-1e44e0f-44b0a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?