类型Alert上不存在Ionic 2警报组件属性创建 [英] Ionic 2 Alert Component property create does not exist on type Alert

查看:198
本文介绍了类型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.

有关在官方Ionic 2博客上创建叠加(包括警报)

编辑:如果你想更新到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:


  1. 使用 rm删除node_modules -rf node_modules /

  2. 运行 npm cache clean

  3. 再次提到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.

这篇关于类型Alert上不存在Ionic 2警报组件属性创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆