vuejs-challenges icon indicating copy to clipboard operation
vuejs-challenges copied to clipboard

218 - 渲染函数[h()]

Open ChenHaoJie9527 opened this issue 3 years ago • 0 comments
trafficstars

// 你的答案
import { defineComponent, h } from 'vue';

export default defineComponent({
  name: 'MyButton',
  props: {
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  emit: ['customClick'],
  setup(props, { emit, slots }) {
    return () =>
      h(
        'button',
        {
          disabled: props.disabled,
          onClick: () => emit('customClick'),
        },
        slots.default?.()
      );
  },
});

ChenHaoJie9527 avatar Aug 09 '22 10:08 ChenHaoJie9527