Ionic 2 警报组件 属性 创建在警报类型上不存在
Ionic 2 Alert Component property create does not exist on type Alert
我在我的 ionic 2
项目中像这样导入 Alert Component
:
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();
但是我的错误是: Property create does not exist on type Alert.
离子信息:
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,其中的做法略有不同。
您应该将 AlertController 注入构造函数。此外,当导入 Alert 时,它有新名称 - AlertController.
更多关于 creating overlays (incluiding alerts) at official Ionic 2 blog 的新方法。
编辑:如果您想更新到 Beta 11,只需 运行:
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 dependency,所以我在我的 Ionic 目录中重新安装了 npm:
- 使用 rm -rf node_modules/
删除 node_modules
- 运行 npm 缓存清理
- 运行 再次提到 npm install 命令
您还需要修复 Beta 11 中的其他更改,如 SO Beta 11 changelog. More on failed npm install due to unmet dependencies 中所述。
我在我的 ionic 2
项目中像这样导入 Alert Component
:
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();
但是我的错误是: Property create does not exist on type Alert.
离子信息:
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,其中的做法略有不同。
您应该将 AlertController 注入构造函数。此外,当导入 Alert 时,它有新名称 - AlertController.
更多关于 creating overlays (incluiding alerts) at official Ionic 2 blog 的新方法。
编辑:如果您想更新到 Beta 11,只需 运行:
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 dependency,所以我在我的 Ionic 目录中重新安装了 npm:
- 使用 rm -rf node_modules/ 删除 node_modules
- 运行 npm 缓存清理
- 运行 再次提到 npm install 命令
您还需要修复 Beta 11 中的其他更改,如 SO Beta 11 changelog. More on failed npm install due to unmet dependencies 中所述。