Skip to content

Input: Vue2 Composition API

import { useStore } from "vuex";
import { defineComponent, toRefs, ref, computed } from "@vue/composition-api";
export default defineComponent({
  name: "CompositionApi",
  props: {
    dirty: {
      type: Boolean,
      required: true,
    },
  },
  setup(props, ctx) {
    const store = useStore();
    const { dirty } = toRefs(props);
    const firstName = ref("first");
    const lastName = ref("last");
    const fullName = computed(() => {
      return firstName.value + lastName.value;
    });
    const isDirty = computed(() => {
      return dirty.value;
    });
    return { firstName, lastName, fullName, isDirty };
  },
});