// 1
import { defineComponent, PropType } from "vue"
import { IFromItem } from "./types"
props: {
fromItem: {
// 給傳遞過來的數據進行類型限制 需要在vue中引入PropType 重新斷言為自己設置的類型。
type: Array as PropType<IFromItem[]>,
// 在vue+ts中props給定默認值為數組或者對象時,使用箭頭函數
default: () => []
},
labelWidth: {
type: String,
default: "100px"
},
},
// 2. 定義數據類型
export interface IFromItem {
label: string
type: "input" | "password" | "select" | "datepicker"
placeholder?: string
// 針對select
options?: any[]
// 針對特殊的屬性
otherOptions?: any
}