//通过接口定义相应的结构
interface Item {
name: string,
icon: string,
url: string,
status:boolean,
initShow:boolean,
copanyStatus:boolean
}
interface IPlist{
title:string,
list:Item[]
}
const menusList:IPlist[] =[{
title: '集团分析',
list: [
{
name: "运行统计",
icon: 'zhuangtaitongji_JT.png,
url: "pages/home/group/move/move",
status:false,
initShow:false,
copanyStatus:true
}
]
}]
// Recode 的使用场景
type petsGroup = 'dog' | 'cat' | 'fish'
interface IPetInfo {
name: string
age: number
}
type IPets = Record<petsGroup, IPetInfo>
const AnimalObj: IPets = {
dog: {
name: 'dog',
age: 2,
},
cat: {
name: 'dog',
age: 2,
},
fish: {
name: 'dog',
age: 2,
},
}
ts 定义对象的常用方式
最新推荐文章于 2024-06-14 16:41:21 发布