【问题标题】:Parameter 'm' implicitly has an 'any' type参数 'm' 隐式具有 'any' 类型
【发布时间】:2018-09-25 07:25:47
【问题描述】:

我在运行我的项目时遇到错误。

这是代码:

private populateModels() {
    var selectedMake = this.makes.find(m => m.id == this.vehicle.makeId);
    this.models = selectedMake ? selectedMake.models : [];
}

这是错误:

ERROR in [at-loader] ./ClientApp/app/components/vehicle-form/vehicle-form.component.ts:82:40
          TS7006: Parameter 'm' implicitly has an 'any' type.

【问题讨论】:

标签: angular angular5


【解决方案1】:

您可以通过这种方式将类型添加到您的 m 变量中:

private populateModels() {
    var selectedMake = this.makes.find( (m: any) => {
        m.id == this.vehicle.makeId);
    });

    this.models = selectedMake ? selectedMake.models : [];
}

因此,您必须添加 m: anym: vehicle,具体取决于您用于模型的类型。这个错误就会消失。

【讨论】:

    猜你喜欢
    • 2018-09-23
    • 2017-11-30
    • 2021-12-24
    • 2021-05-31
    • 2019-03-15
    • 1970-01-01
    • 2019-06-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多