定義包含對象的數(shù)組并賦值
tags: {
name: string
icon: string
}[] = [
{name: '購物消費', icon: 'clothes'},
{name: '食品餐飲', icon: 'foods'},
{name: '居家生活', icon: 'houses'},
{name: '出行交通', icon: 'traffic'},
{name: '虛擬充值', icon: 'game'},
{name: '休閑娛樂', icon: 'dianying'},
];
定義自己的屬性類型
// 定義單個tag的類型
type tag = {
id: string;
name: string;
icon: string
}
type TagListModel = {
// fetch,create览效,save均為函數(shù)
data: tag[]
fetch: () => tag[]
create: (name: string) => string
save: () => void
}