类型Alert上不存在Ionic 2警报组件属性创建
我在我的 ionic 2
项目中导入警报组件
,如下所示:
I've import Alert Component
in my ionic 2
project like this :
import {Alert } from 'ionic-angular';
用法:
let alert = this.alert.create({
title: 'New Friend!',
subTitle: 'Your friend, Obi wan Kenobi, just accepted your friend request!',
buttons: ['OK']
});
alert.present();
但我的错误是: 属性创建确实警报类型不存在。
离子信息
Cordova CLI: 6.3.0
Gulp version: CLI version 1.2.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.10
Ionic CLI Version: 2.0.0-beta.37
Ionic App Lib Version: 2.0.0-beta.20
ios-deploy version: 1.8.6
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v5.12.0
Xcode version: Xcode 7.3 Build version 7D175
我该如何解决?
在我看来,你正在使用新模式创建警报,但你有Ionic Framework 10,其中的事情有所不同。
It seems to me that you are using pieces of new pattern for creating alerts, but you have Ionic Framework 10, where things are done a bit differently.
你应该将AlertController注入构造函数。此外,导入警报时,它具有新名称 - 警报控制器。
You should inject AlertController into constructor. Also, when importing Alert, it has new name - AlertController.
编辑:如果你想更新到Beta 11,只需运行:
edit: If you want to update to Beta 11, just run:
npm install --save --save-exact ionic-angular @angular/common@2.0.0-rc.4 @angular/compiler@2.0.0-rc.4 @angular/core@2.0.0-rc.4 @angular/http@2.0.0-rc.4 @angular/platform-browser@2.0.0-rc.4 @angular/platform-browser-dynamic@2.0.0-rc.4 @angular/forms rxjs@5.0.0-beta.6 zone.js@0.6.12
我有麻烦更新, npm WARN unmet依赖,所以我在我的Ionic目录中重新安装了npm:
I had troubles updating, got npm WARN unmet dependency, so I did reinstall npm in my Ionic directory:
- 使用 rm删除node_modules -rf node_modules /
- 运行 npm cache clean
- 再次提到npm install命令
您还需要修复Beta 11中的其他更改,如 Beta 11更新日志。有关由于未满足的依赖关系而导致npm安装失败的更多信息那么。
You also need to fix other changes in Beta 11, as mentioned at Beta 11 changelog. More on failed npm install due to unmet dependencies at SO.