Skip to content

218 - 渲染函数[h()] #2894

Open
Open
@cone41

Description

@cone41
import { defineComponent, h, defineEmits, defineProps } from 'vue';

export default defineComponent({
  name: 'MyButton',
  props: {
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  emits: ['custom-click'],
  render() {
    return h(
      'button',
      {
        disabled: this.$props.disabled,
        onClick: () => {
          this.$emit('custom-click');
        },
      },
      this.$slots.default?.()
    );
  },
});

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions