vue 自定义按钮组件的点击事件无法生效

  1. 使用vue封装了一个按钮的组件, 但在页面上使用时的点击事件无法生效,也无报错

//myButton
<template>
    <button :type="type" :class="classes" :disabled="disabled">
        <slot>{{label}}</slot>
    </button>
</template>
//App.vue
<my-button :type="button" @click="open">按钮</my-button>
阅读 18.3k
2 个回答

在自定义组件内部:
<button @click="$emit('click', $event)"></button>

推荐问题