DEV Community

Rik Browning
Rik Browning

Posted on

Vue Composition API Components

Component with Props

import { defineComponent } from "@vue/composition-api";
import { Article } from "../models";

export default defineComponent<{ article: Article }>({
  props: {
    article: Object
  },
  ...
});

Component that emits an event

import { defineComponent } from "@vue/composition-api";

export default defineComponent({
  setup(props, ctx) {
    const onClick = () => ctx.emit("like");
    return { onClick };
  }
});

Top comments (0)