๐Ÿ“† 23.03.01 - Vue 3 Composition API์™€ Option API

๋ฒ„๋“คยท2023๋…„ 3์›” 1์ผ
0

โœจToday I Learn (TIL)

๋ชฉ๋ก ๋ณด๊ธฐ
27/62
post-thumbnail

Vue 3๊ฐ€ ์ •์‹ํ™”๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
์ด ํฌ์ŠคํŒ…์€ Vue 3์—์„œ ์ •์‹์œผ๋กœ ๋‚˜์˜ค๊ฒŒ ๋œ Composition API ๋ฅผ ๋‹ค๋ฃจ๊ธฐ ๋•Œ๋ฌธ์— ์ดํ•ด๊ฐ€ ์–ด๋ ค์šฐ์‹  ๋ถ„๋“ค์€ ์ด์ „ ํฌ์ŠคํŒ… ๐Ÿ“† 23.02.10 - Vue 3..! ์ด์ „ ๋ฒ„์ „๊ณผ๋Š” ๋ฌด์—‡์ด ๋‹ฌ๋ผ์กŒ์„๊นŒ ์„ ๋ณด๊ณ  ์™€์ฃผ์„ธ์š”.

Vue 3์—์„œ ๊ณ ๋ฅผ ์ˆ˜ ์žˆ๋Š” 2๊ฐ€์ง€ ์ „์ง

Vue 2์—์„œ๋„ plugin์„ ํ™œ์šฉํ•˜์—ฌ ๊ณ ๋ฅผ ์ˆ˜ ์žˆ์—ˆ๋˜ 2๊ฐ€์ง€ ์ฝ”๋“œ ์ž‘์„ฑ ๋ฐฉ์‹ Composition API์™€ Option API.
์ด๋ฒˆ์— Vue 3๊ฐ€ ์ •์‹ํ™” ๋˜๋ฉด์„œ ๊ธฐ์กด ์–ผ๋ฆฌ์–ผ ๋‹จ๊ณ„์—์„œ์˜ ๋‚ด์šฉ๋ณด๋‹ค ๋” ๋งŽ์€ ๋ถ€๋ถ„์ด Composition API ๋ฌธ๋ฒ•์œผ๋กœ ์ƒ์„ฑ์ด ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜๊ฐ€ ์žˆ๋‹ค.
์ด๋ฒˆ ํฌ์ŠคํŠธ๋Š” Compostion API์™€ Option API๊ฐ€ ์–ด๋– ํ•œ ํ˜•์‹์˜ ๊ตฌ์กฐ๋กœ ์ด๋ฃจ์–ด์ ธ์žˆ๋Š”์ง€ ์ •๋ฆฌํ•˜๊ณ  ์„œ๋กœ์˜ ์ด์  ๋ฐ ์–ด๋– ํ•œ ๊ฒฝ์šฐ์— ์–ด๋–ค ๊ฑธ๋กœ ์ž‘์„ฑํ•ด์•ผ ํ•˜๋Š”์ง€๋ฅผ ๋‹ค๋ฃจ๋ ค๊ณ  ํ•œ๋‹ค.

Composition API์™€ Option API

Vue๋ผ๋Š” ํ”„๋ ˆ์ž„์›Œํฌ๋Š” Single-File Component์˜ ํ˜•์‹์œผ๋กœ HTML ๊ธฐ๋Šฅ์˜ <template>, CSS ๊ธฐ๋Šฅ์˜ <style> ๊ทธ๋ฆฌ๊ณ  JS์˜ <script> ํƒœ๊ทธ์•ˆ์— ์ž‘์„ฑํ•œ ์ฝ”๋“œ๋“ค์„ ์ถ”ํ›„์— ์ปดํŒŒ์ผ ์‹œ, ๊ฐ๊ฐ์˜ ํŒŒ์ผ๋กœ ํŒŒ์‹ฑํ•˜์—ฌ ๋ Œ๋”๋งํ•˜๊ฒŒ ๋˜๋Š” ๊ตฌ์กฐ์ด๋‹ค.

์—ฌ๊ธฐ์„œ <script> ํƒœ๊ทธ์—์„œ ์–ด๋– ํ•œ ํ˜•์‹์œผ๋กœ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๋Š”์ง€์— ๋”ฐ๋ผ์„œ Composition API์™€ Option API ๋ฐฉ์‹์œผ๋กœ ๋‚˜๋‰œ๋‹ค.

ํ•˜๋‹จ์˜ ๊ทธ๋ฆผ์€ ๋‘ ๋ฐฉ์‹์œผ๋กœ ์ž‘์„ฑํ–ˆ์„ ๋•Œ์˜ ์ฐจ์ด๋ฅผ ๋งน๋ชฉ์ ์œผ๋กœ ๋ณด์—ฌ์ค€๋‹ค.

vfcgf

๋จผ์ € ์œ„์˜ ๊ทธ๋ฆผ์„ ๋ณด๋ฉด ๋‘๊ฐ€์ง€ ์ฝ”๋“œ ์˜ค๋ฅธ์ชฝ์˜ ์ฝ”๋“œ๋“ค์ด ๋ฌด์–ธ๊ฐ€ ์ •๊ฐˆํ•˜๊ฒŒ ์—ญํ•  ๊ตฐ์œผ๋กœ ์ •๋ฆฌ๋˜์–ด ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. Composition API ๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋œ ํฐ ์ด์ ์ด ๋ฐ”๋กœ ์ด ๋ถ€๋ถ„์ด๋‹ค.

์žฌ์‚ฌ์šฉ

Composition API๋Š” ๊ธฐ์กด Option API ์˜ ๋กœ์ง ์žฌ์‚ฌ์šฉ ๊ธฐ์ˆ ์ธ mixins์˜ ๋‹จ์ ์„ ํ•ด๊ฒฐํ•˜๊ณ  ๋ฐ˜์‘์„ฑ ์‹œ์Šคํ…œ์— ์‰ฝ๊ฒŒ ํ†ตํ•ฉํ•˜๊ธฐ ์œ„ํ•œ ๊ตฌ์กฐ๋กœ ์งœ์—ฌ์ ธ ์žˆ์–ด ๊นจ๋—ํ•œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ํ”„๋ ˆ์ž„์›Œํฌ์˜ ์—ญํ• ์„ ํ•œ๋‹ค.

๋ณธ๊ฒฉ์ ์ธ ํƒ€์ž…์ถ”๋ก 

Vue 3์—์„œ๋Š” ์ด์ „๋ณด๋‹ค Typescript์˜ ํ˜ธํ™˜์„ฑ์ด ๋†’์•„์กŒ๋‹ค๊ณ  ํ•œ๋‹ค.

๋” ์ž‘์€ ์ƒ์‚ฐ ๋ฒˆ๋“ค ๋ฐ ๋” ์ ์€ ์˜ค๋ฒ„ํ—ค๋“œ

<script setup> ํƒœ๊ทธ๋ฅผ ํ†ตํ•˜์—ฌ ๊ตฌ์„ฑ ์š”์†Œ์˜ ํ…œํ”Œ๋ฆฟ์ด ์ฝ”๋“œ์˜ ๋™์ผํ•œ ๋ฒ”์œ„์— ์ธ๋ผ์ธ๋œ ํ•จ์ˆ˜๋กœ ์ปดํŒŒ์ผ ๋˜๊ธฐ์—, ์ด์ „ Option API ์—์„œ this๋กœ ์ ‘๊ทผํ•˜๋Š” ๊ณผ์ •์„ ์ค„์—ฌ์ฃผ๊ธฐ์— ๋ณ€์ˆ˜ ์ด๋ฆ„์„ ์•ˆ์ „ํ•˜๊ฒŒ ๋‹จ์ถ•๋  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋” ๋‚˜์€ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.

Option API

์ด Option API ๋Š” ์˜ต์…˜์˜ ๊ฐ์ฒด๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ์„ค๊ณ„ํ•˜๊ฒŒ ๋˜๋Š”๋ฐ data, methods, mounted ๋“ฑ์ด ์žˆ๋‹ค. ๋” ์ž์„ธํ•œ ์„ค๋ช…์„ ์œ„ํ•ด ๋‚ด๊ฐ€ ๊ทธ๋™์•ˆ ์ž‘์„ฑํ–ˆ๋˜ ์ฝ”๋“œ๋ฅผ ํ•˜๋‹จ์— ์ฒจ๋ถ€ํ•˜๋ ค๊ณ  ํ•œ๋‹ค. (vue3 ๋ฒ ํƒ€ ๋ฒ„์ „ ๋•Œ ์ž‘์„ฑํ•œ ์ฝ”๋“œ๋ผ ์ผ๋ถ€ ๋ถˆํŽธํ•œ ๋ถ€๋ถ„์ด ์žˆ์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.)

<template>
  <!-- inactive - active ํ† ํƒˆ ์ปจํ…Œ์ด๋„ˆ -->
  <div class="selectContainer__total">
    <!-- ํ™œ์„ฑํ™” ๋˜๊ธฐ ์ „์˜ ์ปจํ…Œ์ด๋„ˆ -->
    <div
      class="selectContainer__inactive"
      @click="Active()"
      :style="{
        transition: $store.state.isActive ? '4s' : '4s',
        opacity: $store.state.isActive ? 0 : 1,
        display: $store.state.isActive ? 'none' : 'inline',
      }"> 
      <!-- ์ดˆ๊ธฐ๊ฐ’ false -->
      <div class="flightContainer">
        <span>
          <h1>{{ shortDep }}</h1>
          {{ getAirport_dep }}
        </span>
        <div>
          <img
            src="./airplane2.png"
            alt="๋น„ํ–‰๊ธฐ"
            :style="airplane_img_inactive" />
        </div>
        <span>
          <h1>{{ shortArr }}</h1>
          {{ getAirport_arr }}
        </span>
      </div>
     
     ...
     
    </div>
  </div>
</template>

<script>
import Button from "../UI/UI/neumorphism/button/Button.vue";
import ToggleButton from "../UI/UI/neumorphism/toggle-button/ToggleButton.vue";
import Datepicker from "vue3-datepicker";
import { mapState, mapGetters, mapActions } from "vuex";
import { defineComponent, ref } from "vue";
// eslint-disable-next-line no-unused-vars
const picked = ref(new Date());
// eslint-disable-next-line no-unused-vars
import { enUS } from "date-fns/locale";
// eslint-disable-next-line no-unused-vars
import { isSameDay } from "date-fns";

export default defineComponent({
  // ๋ฐ์ดํ„ฐ ์ €์žฅํ•˜๋Š” ๊ณณ  {{๋ฐ์ดํ„ฐ๋ฐ”์ธ๋”ฉ}}

  name: "Search-component",
  components: {
    ToggleButton: ToggleButton,
    Button: Button,
    Datepicker: Datepicker,
  },

  data() {
    return {
      inactiveHeight: "15rem",
      picked_from: new Date(),
      picked_to: "",
      toggle: false,
      person: [1, 0, 0],
      selectClass: "",
      openModal: false,
      btnActive: false,
      DepartureDate: "September 17th",
      ArrivalDate: "October 15th",

      airplane_img_inactive: {
        width: "30px",
        height: "30px",
        marginTop: "20px",
        marginLeft: "auto",
        marginRight: "auto",
      },

  },

  methods: {
    Active() {
      this.$store.state.isActive = true;
    },
    unActive() {
      this.$store.state.isActive = false;
    },
    reverse() {
      /* shortDep <-> shortArr */
      this.$store.state.tem_short = this.$store.state.arrival;
      this.$store.state.arrival = this.$store.state.departure;
      this.$store.state.departure = this.$store.state.tem_short;
      /* getAirport_dep <-> getAirport_arr */
      this.$store.state.tem_airport = this.$store.state.airport_arr;
      this.$store.state.airport_arr = this.$store.state.airport_dep;
      this.$store.state.airport_dep = this.$store.state.tem_airport;
      /*.depAirportId <-> arrAirportId */
      this.$store.state.tem_code = this.$store.state.arrAirportId;
      this.$store.state.arrAirportId = this.$store.state.depAirportId;
      this.$store.state.depAirportId = this.$store.state.tem_code;
      /* tem_depNm _<-> tem_arrNm */
      this.$store.state.tem_DepArrNm = this.$store.state.tem_depNm;
      this.$store.state.tem_depNm = this.$store.state.tem_arrNm;
      this.$store.state.tem_arrNm = this.$store.state.tem_DepArrNm;
    },
    // ํ•œ๊ณ„์น˜๋ฅผ ๋„˜์œผ๋ฉด ๋ฒ„ํŠผ ์ž ๊ทธ๊ธฐ
    btnIncrease() {
      if (document.querySelector("input[id=adult]:checked")) this.person[0]++;
      else if (document.querySelector("input[id=kid]:checked"))
        this.person[1]++;
      else this.person[2]++;

      /* Prevent from over 9 */
      
   ...
   
  },

  computed: {
    ...mapState(["arrival", "departure", "tem_short", "selectClass"]),
    ...mapGetters({
      shortDep: "shortDep",
      shortArr: "shortArr",
      getAirport_dep: "getAirport_dep",
      getAirport_arr: "getAirport_arr",
    }),
    ...mapActions({
      searchInfo: "searchInfo",
    }),
    /* phoneHeight() {
        return window.matchMedia('screen and (max-width: 440px)').matches ? '60vh' : '35rem'
    }, */
    activeHeight() {
      return document.getElementsByClassName("selectContainer__active").height;
    },
  },

  watch: {},
});
</script>

<style lang="scss" scoped>
@import "../UI/scss/main.scss";
...

* {
  perspective: 700px;
  user-select: none; // prevent block
}

html {
  font-size: 16px;
}

.selectContainer {
  margin: {
    top: 15px;
    
    </style>

degineComponent ๋ผ๋Š” ๊ฐ์ฒด ์•ˆ์—์„œ ์‹ค์งˆ์ ์ธ data๋ฅผ ๋‹ค๋ฃจ๋Š” data(), ํ•จ์ˆ˜๋ฅผ ๋‹ค๋ฃจ๋Š” methods, ์บ์‹ฑ ์ฒ˜๋ฆฌ๋œ computed ๋“ฑ์˜ ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ปดํฌ๋„ŒํŠธ ๋กœ์ง์„ ์ •์˜ํ•˜๊ฒŒ๋œ๋‹ค. ๋˜ํ•œ vue์˜ ๋ผ์ดํ”„์‚ฌ์ดํด ์„ ํ‘œํ˜„ํ•˜๋Š” mounted(), created() ๋“ฑ์œผ๋กœ ์ง์ ‘์ ์ธ ํ‘œํ˜„์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

this

๋˜ํ•œ Option API์—์„œ์˜ ์˜ต์…˜์œผ๋กœ ์ •์˜๋œ ์†์„ฑ๋“ค์€ Component Instance ๋ฅผ ๊ฐ€๋ฅดํ‚ค๋Š” ํ•จ์ˆ˜ ๋‚ด๋ถ€์˜ this ๋กœ ๋…ธ์ถœ์ด ๋œ๋‹ค๊ณ  ํ•œ๋‹ค.

์œ„์˜ methods ์—์„œ data ๊ฐ์ฒด์˜ ๊ฐ’์„ ์‚ฌ์šฉํ•  ๋•Œ๋„ this๋ฅผ ์ ‘๋‘์‚ฌ๋กœ ์”€์œผ๋กœ, ๊บผ๋‚ด์„œ ์“ฐ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

Composition API

Composotion API๋ž€ ์˜ต์…˜์„ ์„ ์–ธํ•˜๋Š” ๋Œ€์‹  ๊ฐ€์ ธ์˜จ ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Vue๋ฅผ ์ž‘์„ฑํ•˜๊ฒŒ ํ•ด์ฃผ๋Š” API ์ž‘์„ฑ ๊ธฐ๋ฒ•์ด๋ผ๊ณ  ํ•˜๋Š”๋ฐ ์ƒ๊ธด ๊ฒƒ์„ ๋ณด๋ฉด React์—์„œ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ์‹๊ณผ ์œ ์‚ฌํ•œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

์•„๋ž˜์˜ ์ฝ”๋“œ๋Š” vue ๊ณต์‹ ํ™ˆํŽ˜์ด์ง€์—์„œ ์ธ์šฉ์„ ํ•ด์™”๋‹ค.

<script setup>
import { ref, onMounted } from 'vue'

// reactive state
const count = ref(0)

// functions that mutate state and trigger updates
function increment() {
  count.value++
}

// lifecycle hooks
onMounted(() => {
  console.log(`The initial count is ${count.value}.`)
})
</script>

<template>
  <button @click="increment">Count is: {{ count }}</button>
</template>

์œก์•ˆ์œผ๋กœ ๋ดค์„ ๋•Œ ๋‹ฌ๋ผ์ง„ ๋ถ€๋ถ„์„ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ •๋ฆฌํ•ด ๋ณด์•˜์„ ๋•Œ..

  • JS ๋ฌธ๋‹จ์„ ์‚ฌ์šฉํ•˜๋Š” <script> ํƒœ๊ทธ๊ฐ€ <script setup> ํƒœ๊ทธ๋กœ ๋ณ€๊ฒฝ
  • ํ•จ์ˆ˜๋‚˜ ๋ณ€์ˆ˜ ๋“ฑ์„ ๋” ์ด์ƒ ๊ฐ์ฒด ์•ˆ์—์„œ๊ฐ€ ์•„๋‹Œ ๋ฆฌ์•กํŠธ ์ปดํฌ๋„ŒํŠธ ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ณ€์ˆ˜ ํƒ€์ž…์„ ์ง€์ •ํ•˜๊ณ  ์„ค๊ณ„
  • ๋ผ์ดํ”„์‚ฌ์ดํด ํ•จ์ˆ˜๊ฐ€ Option API ์—์„œ ์‚ฌ์šฉํ–ˆ๋˜ ์ง๊ด€์ ์ธ ๋„ค์ด๋ฐ์—์„œ ์กฐ๊ธˆ ๋ฒ—์–ด๋‚ฌ์œผ๋ฉฐ, ๊ฐ์ž์˜ ๋ผ์ดํ”„์‚ฌ์ดํด ์ด๋ฆ„์˜ ํ•จ์ˆ˜๋กœ ๊ฐ๊ฐ ๋”ฐ๋กœ๋”ฐ๋กœ ์ž‘์„ฑํ•˜๋Š” ๋ชจ์–‘์œผ๋กœ ๋ณด์ž„

ํ•˜์ง€๋งŒ ์ •ํ™•ํ•˜๊ฒŒ ๋„˜์–ด๊ฐ€๋Š” ๊ฒƒ์ด ์ข‹์œผ๋‹ˆ ๊ฐœ๋ฐœ์ž๋“ค์˜ ์นœ๊ตฌ ๊ณต์‹๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ Composition API ์˜ ์ •์˜๋ฅผ ์‚ดํŽด๋ณด๋ ค๊ณ  ํ•œ๋‹ค.

Composition API ๊ฐ„๋‹จ ์ •๋ฆฌ

์˜ต์…˜ ์„ ์–ธ์„ ํ•˜๋˜ ๋ฐฉ์‹์—์„œ ํ•จ์ˆ˜ ๊ตฌ์„ฑ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๋Š” API ์Šคํƒ€์ผ๋กœ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ์‹์„ ์˜๋ฏธํ•œ๋‹ค.
(๊ทธ๋ ‡์ง€๋งŒ Composition API๋Š” Vue์˜ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•˜๊ณ  ์„ธ๋ถ„ํ™”๋œ ๋ฐ˜์‘์„ฑ ํŒจ๋Ÿฌ๋‹ค์ž„์„ ๊ธฐ๋ฐ˜์œผ๋กœ ์ž‘์„ฑ๋˜๊ธฐ์— ๋ถˆ๋ณ€์„ฑ์„ ๊ฐ•์กฐํ•˜๋Š” ํ•จ์ˆ˜ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด ์•„๋‹ˆ๋‹ค)

  • ๋ฐ˜์‘์„ฑ API ๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ๋‹ค.ref(), reactive()๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ˜์‘์„ฑ ์ƒํƒœ, ๊ณ„์‚ฐ๋œ ์ƒํƒœ ๋ฐ ๊ฐ์‹œ์ž๋ฅผ ์ง์ ‘ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.

  • ๋ผ์ดํ”„์‚ฌ์ดํด ํ›…์„ ๋”ฐ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ex ) onMounted(), onCreated()

  • ๋ฐ˜์‘์„ฑ API๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋™์•ˆ Vue์˜ ์˜์กด์„ฑ ์ฃผ์ž… ์‹œ์Šคํ…์„ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ฃผ๋Š” provide(), inject() ์ƒ์„ฑ

์›๋ž˜ ์ด Composition API๋Š” Vue 3 ์—์„œ์˜ ๋ชจ๋ธ ์ด๊ธฐ์— Vue 2 ์œ ์ €๋“ค์€ Vue 2.7๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ, ํ˜น์€ @vue/composition-api ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์„ค์น˜ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค๊ณ  ํ•œ๋‹ค.


๊ทธ๋ ‡๋‹ค๋ฉด Option API ์—์„œ Composition API๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ํ•ด์•ผํ•˜๋‚˜์š”?

๊ผญ ๊ทธ๋ ‡๋‹ค๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๋ผ๊ณ  ํ•œ๋‹ค. Option API์˜ ํฐ ์žฅ์ ์€ ์ค‘, ์†Œ๊ทœ๋ชจ์˜ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค ๋•Œ๋Š” ์ƒ๊ฐ์„ ๋œ ํ•  ์ˆ˜ ์žˆ๊ฒŒ๋˜์–ด ํฐ ์‚ฌ๋ž‘์„ ๋ฐ›๋Š”๋‹ค๋Š” ์ ์ด๋‹ค. ํ•˜์ง€๋งŒ, ๋Œ€๊ทœ๋ชจ ํ”„๋กœ์ ํŠธ์—์„œ๋Š” ์—ฌ๋Ÿฌ ์žฌ์‚ฌ์šฉ๋˜๋Š” ๋กœ์ง๋“ค์˜ ๊ฐ€์ง“์ˆ˜๋“ค์ด ๋Š˜์–ด๋‚˜๊ธฐ์— Composition API ๋ฅผ ์ถ”์ฒœํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.

๋”ฐ๋ผ์„œ ์šฐ๋ฆฌ์˜ ํ”„๋กœ์ ํŠธ์˜ ๊ทœ๋ชจ๊ฐ€ ์–ด๋–ป๊ฒŒ ๋  ๊ฒƒ์ธ์ง€ ๊ฐ€์ •ํ•˜๊ณ  ์„ค๊ณ„๋ฅผ ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค

Reference : https://vuejs.org/guide/extras/composition-api-faq.html

profile
ํƒœ์–ด๋‚œ ๊น€์— ๋งŽ์€ ๊ฒฝํ—˜์„ ํ•˜๋ ค๊ณ  ์•„๋“ฑ๋ฐ”๋“ฑ ์• ์“ฐ๋Š” ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž

0๊ฐœ์˜ ๋Œ“๊ธ€