首页 > 解决方案 > “EventEmitter”类型上不存在属性“自定义”'

问题描述

我正在使用 ionic 3,并且我有一个部件组件和一个部件页面

Parts.html 页面:

<ion-row> 
   <part [part]="part"></part>
</ion-row>

parts.html的part变量是这个 json:

在此处输入图像描述

Part.ts 组件:

import { Component, ViewChild, Input, EventEmitter } from "@angular/core";

export class PartComponent {
    @Input() part = new EventEmitter<any>();

    ngAfterViewInit(){
        this.setInitialValues();
    }
    ngOnChanges(){
        this.setInitialValues();
    }

    setInitialValues() {
      console.log(this.part);
      if (this.part) {

        if (this.part.hasOwnProperty('parts') && this.part.parts.length != 0) {
          this.hasParts = true;
        }
        this.getPartQuestionnaire(this.part.id);
      }
    }

我在构建离子应用程序时遇到了这个错误:

“EventEmitter”类型上不存在属性“parts”。

L81: if (this.part.hasOwnProperty('parts') && this.part.parts.length != 0) {

L82:this.hasParts = true;

“EventEmitter”类型上不存在属性“id ”。

L84: this.getPartQuestionnaire(this.part.id);

当我评论 part.ts 的这行并在控制台中显示变量部分时,我得到了 foow 图像表示,其中前 2 个调用显示为空,但在它加载部分值之后:

在此处输入图像描述

尝试构建应用程序时如何解决此错误?

我正在建造ionic cordova run browser

标签: angularasynchronousionic3

解决方案


换行试试

 @Input() part = new EventEmitter<any>();

@Input() part : any;

推荐阅读