【发布时间】:2017-11-01 01:35:32
【问题描述】:
我的 html 文件中有一个简单的离子选择组件,如下所示:
<ion-row><ion-item class="login-item">
<ion-label floating> Companies</ion-label>
<ion-select [(ngModel)]="storeid">
<ion-option value="1"> store1</ion-option>
<ion-option value="2"> store2</ion-option>
</ion-select>
</ion-item></ion-row>
而我的 package.json 是这样的:
{
"name": "ionic-hello-world",
"version": "0.0.0",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "4.0.2",
"@angular/compiler": "4.0.2",
"@angular/compiler-cli": "4.0.2",
"@angular/core": "4.0.2",
"@angular/forms": "4.0.2",
"@angular/http": "4.0.2",
"@angular/platform-browser": "4.0.2",
"@angular/platform-browser-dynamic": "4.0.2",
"@ionic-native/core": "3.4.2",
"@ionic-native/splash-screen": "3.4.2",
"@ionic-native/status-bar": "3.4.2",
"@ionic/storage": "2.0.1",
"angular2-swing": "^0.7.1",
"ionic-angular": "3.2.1",
"ionic2-auto-complete": "^1.4.2-release",
"ionic2-super-tabs": "^2.3.0",
"ionicons": "3.0.0",
"ng2-swipe-cards": "^1.0.14",
"rxjs": "5.1.1",
"sw-toolbox": "3.4.0",
"zone.js": "^0.8.5"
},
"devDependencies": {
"@ionic/app-scripts": "1.3.6",
"typescript": "~2.2.1"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"ionic-plugin-keyboard",
"cordova-plugin-splashscreen"
],
"cordovaPlatforms": [],
"description": "An Ionic project"
}
当我单击视图中的选择时,它崩溃并且运行时错误堆栈如下:
TypeError: Cannot read property '_getPortal' of undefined
at App.present (http://localhost:8100/build/main.js:17984:52)
at Alert.present (http://localhost:8100/build/main.js:49299:26)
at Select.open (http://localhost:8100/build/main.js:71893:17)
at Select._click (http://localhost:8100/build/main.js:71758:14)
at Object.eval [as handleEvent] (ng:///AboutModule/About.ngfactory.js:433:43)
at handleEvent (http://localhost:8100/build/main.js:12303:138)
at callWithDebugContext (http://localhost:8100/build/main.js:13511:42)
at Object.debugHandleEvent [as handleEvent] (http://localhost:8100/build/main.js:13099:12)
at dispatchEvent (http://localhost:8100/build/main.js:9278:21)
at http://localhost:8100/build/main.js:9868:38
一切都那么简单,我不明白可能是什么问题。
【问题讨论】:
-
你的代码中有
_getPortal吗? -
不,我没有在我的源代码中使用任何名为“门户”的东西。错误来自 main.js 中的 main.js _getPortal 它在最终编译的代码中使用: App.prototype.getActiveNav = function () { var /** @type {?} /portal = this._appRoot._getPortal( __WEBPACK_IMPORTED_MODULE_2__app_constants__["b" / PORTAL_MODAL */]); if (portal.length() > 0) { return findTopNav(portal); } 返回 findTopNav(this._rootNav || null); };
-
main.js App.prototype.present = function (enteringView, opts, appPortal) { (void 0) /* assert /; var /* @type {?} */ portal = this._appRoot._getPortal(appPortal); // 必须在此处设置 Set Nav 才能使 dimiss() 同步工作。 // TODO: 将 _setNav() 移到 NavController 的早期阶段。 _queueTrns()进入View._setNav(portal);
-
显示你的组件(类)代码。正在使用此选择项。
-
main.ts 用于引导您的应用程序。所以检查你的根组件。如果您在那里定义了任何名称为 _getPortal 的属性并且具有未定义的含义,那么它什么都没有并且您正在使用此属性。
标签: ionic-framework ionic2 ionic3