Vue3之PropType

您所在的位置:网站首页 proptype Vue3之PropType

Vue3之PropType

#Vue3之PropType| 来源: 网络整理| 查看: 265

PropType export type ButtonType = 'default' | 'primary' | 'success' | 'warning' | 'danger'; export const makeStringProp = (defaultVal: T) => { type: String as unknown as PropType, default: defaultVal }; export const makeArrayProp = () => ({ type: Array as PropType, default: () => [], }); export const truthProp = { type: Boolean, default: true as const, }; export default defineComponent({ props: { title: makeStringProp('default'), tag: makeStringProp('button'), } }); // 2 import type {PropType} from 'vue'; export interface TodoItem { text: string done: boolean } props: { todo: { type: Object as PropType, default: { text: '', done: false } } } 双重断言

basarat.gitbook.io/typescript/…



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3