vue3 emit事件

 

   <div id="vm">
        <div>子组件点击时:{{count}}</div>
        <blog-post @myaddevent='fuaddevent'></blog-post>
    </div>
    <script type="module">
        import * as obj from './main.js'
        const app = Vue.createApp({
            data() {
                return {
                    count: 0
                }
            },
            methods: {
                fuaddevent(data) {
                    this.count += data;
                }
            }
        });
        app.component('blog-post', obj.btn1)
        const vm = app.mount('#vm');
    </script>

main.js

const btn1 = {
    template: `<button @click="add(1)">增加</button>`,
    methods: {
        add(num) {
            this.$emit('myaddevent',num)
        }
    }
}
export { btn1 }

vue3 emit事件

 

上一篇:【强化学习】表格型求解方法总结:基于表格型方法(Tabular Methods)的规划(Planning)和学习(Learning)


下一篇:cors时session取数据失败