<var id="z5l9h"><strike id="z5l9h"><progress id="z5l9h"></progress></strike></var>
<thead id="z5l9h"></thead>
<cite id="z5l9h"><strike id="z5l9h"><listing id="z5l9h"></listing></strike></cite>
<var id="z5l9h"></var>
<ins id="z5l9h"><strike id="z5l9h"></strike></ins> <var id="z5l9h"></var>
<var id="z5l9h"><dl id="z5l9h"></dl></var>
<var id="z5l9h"><strike id="z5l9h"><progress id="z5l9h"></progress></strike></var>

打字稿错误:找不到名字’cordova’

import {Component} from '@angular/core';
import {NavController, Platform, AlertController} from 'ionic-angular';
import {Transfer, TransferObject} from '@ionic-native/transfer';
import {File} from '@ionic-native/file';



@Component({
  selector: 'page-about',
  templateUrl: 'about.html',
  providers: [Transfer, TransferObject, File]
})
export class AboutPage {

  storageDirectory: string = '';

  constructor(public navCtrl: NavController, public platform: Platform, private transfer: Transfer, private file: File, public alertCtrl: AlertController) {
    this.platform.ready().then(() => {
      // make sure this is on a device, not an emulation (e.g. chrome tools device mode)
      if(!this.platform.is('cordova')) {
        return false;
      }

      if (this.platform.is('ios')) {
        this.storageDirectory = cordova.file.documentsDirectory;
      }
      else if(this.platform.is('android')) {
        this.storageDirectory = cordova.file.externalDataDirectory;
		console.log(this.storageDirectory);
      }
      else {
        // exit otherwise, but you could add further types here e.g. Windows
        return false;
      }
    });
  }
  
   downloadImage() {

    this.platform.ready().then(() => {

      const fileTransfer: TransferObject = this.transfer.create();

      const imageLocation = 'http://html5demos.com/assets/dizzy.mp4';

      fileTransfer.download(imageLocation, this.storageDirectory + 'dizzy.mp4').then((entry) => {
       
	   const alertSuccess = this.alertCtrl.create({
          title: `Download Succeeded!`,
          subTitle: `successfully downloaded to: ${entry.toURL()}`,
          buttons: ['Ok']
        });

        alertSuccess.present();

      }, (error) => {

        const alertFailure = this.alertCtrl.create({
          title: `Download Failed!`,
          subTitle: `was not downloaded. Error code: ${error}`,
          buttons: ['Ok']
        });

        alertFailure.present();

      });

    });

  }


}

I am getting the error attached in screenshot.我在离子2中运行我的项目构建时遇到错误,虽然我已经使用下面的命令安装了’typings’

npm install -g typings typings,安装dt~cordova –save –global

并尝试了每种可能的方法来删除此错误,检查所有cordova插件,如文件,文件传输但仍然错误无法解决.

任何人都可以寻找它.

这里附有代码,我也不知道我哪里出错了..

我编辑了你的代码,添加了declare let cordova:any;这暴露了cordova api以供使用.希望这有帮助.

import {Component} from '@angular/core';
import {NavController, Platform, AlertController} from 'ionic-angular';
import {Transfer, TransferObject} from '@ionic-native/transfer';
import {File} from '@ionic-native/file';

declare let cordova: any;

@Component({
  selector: 'page-about',
  templateUrl: 'about.html',
  providers: [Transfer, TransferObject, File]
})
export class AboutPage {

  storageDirectory: string = '';

  constructor(public navCtrl: NavController, public platform: Platform, private transfer: Transfer, private file: File, public alertCtrl: AlertController) {
    this.platform.ready().then(() => {
      // make sure this is on a device, not an emulation (e.g. chrome tools device mode)
      if(!this.platform.is('cordova')) {
        return false;
      }

      if (this.platform.is('ios')) {
        this.storageDirectory = cordova.file.documentsDirectory;
      }
      else if(this.platform.is('android')) {
        this.storageDirectory = cordova.file.externalDataDirectory;
		console.log(this.storageDirectory);
      }
      else {
        // exit otherwise, but you could add further types here e.g. Windows
        return false;
      }
    });
  }
  
   downloadImage() {

    this.platform.ready().then(() => {

      const fileTransfer: TransferObject = this.transfer.create();

      const imageLocation = 'http://html5demos.com/assets/dizzy.mp4';

      fileTransfer.download(imageLocation, this.storageDirectory + 'dizzy.mp4').then((entry) => {
       
	   const alertSuccess = this.alertCtrl.create({
          title: `Download Succeeded!`,
          subTitle: `successfully downloaded to: ${entry.toURL()}`,
          buttons: ['Ok']
        });

        alertSuccess.present();

      }, (error) => {

        const alertFailure = this.alertCtrl.create({
          title: `Download Failed!`,
          subTitle: `was not downloaded. Error code: ${error}`,
          buttons: ['Ok']
        });

        alertFailure.present();

      });

    });

  }


}
相关文章
761111香港马会查询无错九肖 岳阳县| 鄂托克前旗| 开鲁县| 麟游县| 奉新县| 中西区| 利川市| 长阳| 通辽市| 连云港市| 东乡族自治县| 横峰县| 苍溪县| 奎屯市| 忻州市| 扬中市| 沂水县| 平顶山市| 雷山县| 三穗县| 崇左市| 琼海市| 明光市| 孙吴县| 巴彦县| 介休市| 静宁县| 昭觉县| 百色市| 浠水县| 观塘区| 商丘市| 广宗县| 文昌市| 西城区| 古蔺县| 安溪县| 武功县| 扶余县| 马公市| 江西省| 会理县| 西安市| 大英县| 庄浪县| 手游| 阜城县| 望都县| 西乌珠穆沁旗| 贡嘎县| 拜城县| 邯郸市| 开化县| 雅安市| 喀什市| 石泉县| 尖扎县| 高州市| 成都市| 璧山县| 夹江县| 孟津县| 永和县| 隆化县| 望谟县| 颍上县| 宝鸡市| 嘉善县| 云林县| 大冶市| 巍山| 武陟县| 大庆市| 同心县| 沛县| 剑河县| 积石山| 子长县| 萍乡市| 宜良县| 中西区| 顺平县| 福州市| 汝南县| 台北市| 星座| 余姚市| http://hwinr888.com http://3g.hspendr888.com http://wap.flskino888.com http://wap.gwvisitl888.com http://htermr888.com http://3g.hsitr888.com http://wap.flseeko888.com http://3g.hstopr888.com http://3g.htoolr888.com http://3g.gwritel888.com http://wap.hslowr888.com