vue.js关于组件里面的input事件的疑问

如下代码vue在$emit`里面的input`参数到底值得是什么意思?还请指点一下,谢谢

<body>

<div id="app">
    你现在的银行卡余额是{{totale}}
    <!-- <appcom @change="handletotel"></appcom> -->
    <appcom v-model=" totale"></appcom>
</div>
<script>
    var cl = new Vue({
        el: '#app',
        data: {
            jk: 'this is father',
            totale: 2000 /*银行卡余额是2000元*/
        },
        methods: {
            // handletotel(value){
            //        //此处的形参value就是传递过来的数值
            //        this.totale=value;
            // }
        },
        components: {
            'appcom': {
                template: '<div>\
                <div @click="haderplus">+1000</div>\
                <div @click="hadercl">-1000</div>\
                </div>',
                /*为什么{{c}}会被渲染出来*/
                props: ['kl'],
                data() {
                    return {
                        count: 2000
                    }
                },
                methods: {
                    haderplus() {
                        this.count = this.count + 1000;
                        this.$emit('input', this.count)
                    },
                    hadercl() {
                        this.count = this.count - 1000;
                        this.$emit('input', this.count);
                    }
                }
            }
        }

    })
</script>

</body>

阅读 1.6k
2 个回答

v-model的语法糖,不过组件props应该有value传入

可以了解下,vue父子组件通讯

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题