feat: 函数式弹窗示例代码添加子组件propprimitive类型的demo (#587)

This commit is contained in:
ChasonZheng
2023-06-07 21:59:02 +08:00
committed by GitHub
parent f613a79def
commit 3471e4a7e2
3 changed files with 57 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
<script setup lang="ts">
import { useVModel } from "@vueuse/core";
// 声明 props 类型
export interface FormProps {
data: string;
}
// 声明 props 默认值
// 推荐阅读https://cn.vuejs.org/guide/typescript/composition-api.html#typing-component-props
const props = withDefaults(defineProps<FormProps>(), {
data: () => ""
});
// 使用 vueuse 的双向绑定工具
const emit = defineEmits(["update:data"]);
const data = useVModel(props, "data", emit);
</script>
<template>
<el-input class="!w-[220px]" v-model="data" placeholder="请输入内容" />
</template>