gpt4 book ai didi

Ionic2:运行时错误无法读取未定义的属性 'prototype'

转载 作者:行者123 更新时间:2023-12-03 19:39:23 25 4
gpt4 key购买 nike

我正在使用 Ionic2 并收到此错误:

Runtime Error
Cannot read property 'prototype' of undefined


阅读 herehere ,它表明它可能与声明子类和基类的顺序有关。我正在使用带有子类的基类。您在哪里更改它们的声明顺序,是在进口中吗?在什么文件里?

有趣的是我的代码运行良好,突然开始出现此错误,即使我没有更改基类或子类。我确实对另一个文件进行了更改,现在已恢复,但仍然出现错误。

更多细节:

错误:

main.js:24046Uncaught TypeError: Cannot read property 'prototype' of undefined
at __extends (main.js:24046)
at job.ts:26
at Object.<anonymous> (job.ts:24)
at __webpack_require__ (bootstrap cdd11c2…:19)
at Object.<anonymous> (main.js:46012)
at __webpack_require__ (bootstrap cdd11c2…:19)
at Object.<anonymous> (personModel.ts:21)
at __webpack_require__ (bootstrap cdd11c2…:19)
at Object.<anonymous> (locationModel.ts:11)


代码:

工作.ts
import { Component, ViewChild, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { NavController, NavParams, InfiniteScroll, Content, Platform, Events, AlertController, LoadingController, ViewController, PopoverController } from 'ionic-angular';
import { JobModel } from '../model/jobModel';
import { PersonModel } from '../model/personModel';
import { SubCategoryModel } from '../model/subCategoryModel';
import { LocationModel } from '../model/locationModel';
import { RatingModel } from '../model/ratingModel';
import { ReviewPage } from '../review/review';
import { ChatsPage } from '../chats/chats';
import { CategoryPage } from '../category/category';
import { PersonPage } from '../person/person';
import { MyCameraPage } from '../mycamera/mycamera';
import { JobService } from '../service/jobService';
import { PersonService } from '../service/personService';
import { RatingService } from '../service/ratingService';
import { UtilityService } from '../utils/utilityService';
import { SearchJobsParent } from '../searchjobs/searchjobsParent';
import { MapRangeService } from '../service/mapRangeService';

@Component({
selector: 'job',
templateUrl: 'job.html',
changeDetection: ChangeDetectionStrategy.OnPush
})

export class JobPage extends SearchJobsParent {
@ViewChild(Content) content: Content;
.....

searchJobsParent.ts
...
@Component({
})
export class SearchJobsParent {
...

ionic 信息
Your system information:

Cordova CLI: You have been opted out of telemetry. To change this, run: cordova telemetry on.
6.4.0

Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v6.9.4
Xcode version: Not installed

最佳答案

我通过使用组合而不是继承解决了这个问题。

您创建一个类的实例,您在以下方面具有通用功能:

myClas.ts

private someCommonClass: SomeCommonClass = null;
...
this.someCommonClass = new SomeCommonClass(platform, ref);

someCommonClass.ts
constructor(platform: Platform)

关于Ionic2:运行时错误无法读取未定义的属性 'prototype',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41807743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com