小编Her*_*aya的帖子

错误TS2345:类型"菜单"的参数不能分配给类型的参数

美好的一天.我是使用VSCode的Type Script的新手.

获得以下错误:

error TS2345: Argument of type 'Menu' is not assignable to parameter of type '{ state: string; name: string; type: string; icon: string;
 badge?: undefined; children?: undefine...'
Run Code Online (Sandbox Code Playgroud)

代码:

import { Injectable } from '@angular/core';

export interface BadgeItem {
  type: string;
  value: string;
}

export interface ChildrenItems {
  state: string;
  name: string;
  type?: string;
}

export interface Menu {
  state: string;
  name: string;
  type: string;
  icon: string;
  badge?: BadgeItem[];
  children?: ChildrenItems[];
}

const MENUITEMS = …
Run Code Online (Sandbox Code Playgroud)

typescript angular

1
推荐指数
1
解决办法
1425
查看次数

标签 统计

angular ×1

typescript ×1