Vue 3.2 defineProps 用法

2023/03/10閱讀時間約 1 分鐘
  • 父元件
傳遞變數時須加上冒號
<template>
    <Product :main_category_id="main_category_id" :sub_category_id="sub_category_id"/>
</template>
  • 子元件
接收props用法如下
<script setup>
    const props = defineProps({
        main_category_id: String,
        sub_category_id: String
    });
  //props.main_category_id
</script>
本筆記參考:
為什麼會看到廣告
20會員
161內容數
留言0
查看全部
發表第一個留言支持創作者!