首页 > 解决方案 > 如何为以下日期类型定义接口

问题描述

我正在尝试为 this.usedPercentageFilterOptions 定义接口类型。你知道下面的接口声明是否正确吗?

`

  interface Item {
     filterPillValue: string,
     id: string,
    label: string
}
interface Items {
    radio: Item,
    checkbox: Item
}
   public usedPercentageFilterOptions: Items[]

   this.usedPercentageFilterOptions = [
        {
          radio:  { filterPillValue: 'used%', id:'filter-used-%', label: 'Used %' },
          checkbox: [
            { filterPillValue: 'Full', id:'filter-full', label: 'Full' },
            { filterPillValue: 'Reached Critical threshold', id:'filter-critical-threshold', label: 'Reached Critical threshold' },
            { filterPillValue: 'Reached Warning threshold', id:'filter-warning-threshold', label: 'Reached Warning threshold' },
            { filterPillValue: 'Not reached threshold', id:'filter-not-reached-threshold', label: 'Not reached threshold' }
          ]
        }
    ];`

标签: angulartypescriptecmascript-6interfaceangular9

解决方案


尝试这个

 export interface Cb {
       filterPillValue?: string;
       id?: string;
       label?: string
    }

export interface UsedPer {
       radio?: Cb;
       checkbox?: Cb[]
   }

希望有用


推荐阅读