setup

Composition API 功能要寫在setup裡面

<script>
export defalut {
  setup(){
    //...
  }
}
</script>

也可以寫成

<script setup>
</script>

ref

  • 定義響應性數據
  • 參數名稱要+.value來修改資料
<template>
  <h1>{{ title }}</h1>
</template> 
<script setup>
import { ref } from 'vue';
const title = ref('title');
title.value = 'new title';
</script>