【发布时间】:2023-01-24 02:00:42
【问题描述】:
我正在尝试用打字稿中的 Vue 3 脚本设置语法替换我的 Vue 2 选项 API 道具对象代码。
现存的:
type: {
type: String,
default: 'button',
validator: (prop) => ['button', 'submit', 'reset'].includes(prop)
}
到目前为止我有这个:
<script lang="ts" setup>
interface Props {
type?: string;
}
const props = withDefaults(defineProps<Props>(), { type: 'button' });
</script>
但我找不到任何关于如何在脚本设置语法中处理道具验证器的信息
【问题讨论】:
标签: typescript vuejs3