【问题标题】:What is the required type argument?所需的类型参数是什么?
【发布时间】:2017-02-12 03:54:09
【问题描述】:

错误 TS2314:在我的 app.component.ts 页面中升级 ionic 2.1.0 时,通用类型“类型”需要 1 个类型参数。

【问题讨论】:

标签: angular typescript ionic2


【解决方案1】:

所需的类型参数是什么?

当某些东西需要通用但未提供时。例如

class Foo<T>{
    data:T
}

class Bar extends Foo { } // Missing generic argument

修复

提供通用参数,例如

class Foo<T>{
    data:T
}

class Bar extends Foo<number> { }

【讨论】:

  • public rootPage: Type&lt;string&gt;; public pages: Array&lt;{title: string, component: Type&lt;string&gt;}&gt; 我想给什么而不是字符串?
  • ` this.rootPage = DashboardPage; this.initializeApp(); this.pages = [ { 'title': 'Dashboard', component: DashboardPage }'。如果我将参数作为字符串,我在粗体部分有错误。
猜你喜欢
  • 2019-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-22
相关资源
最近更新 更多