• <bdo id="2geeg"><optgroup id="2geeg"></optgroup></bdo>
    <rt id="2geeg"><optgroup id="2geeg"></optgroup></rt><kbd id="2geeg"><tr id="2geeg"></tr></kbd>
    <sup id="2geeg"><optgroup id="2geeg"></optgroup></sup><optgroup id="2geeg"><acronym id="2geeg"></acronym></optgroup>
    <input id="2geeg"><samp id="2geeg"></samp></input>
  • <rt id="2geeg"><optgroup id="2geeg"></optgroup></rt>

    打字稿错误:找不到名字’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();
    
          });
    
        });
    
      }
    
    
    }
    相关文章
    惠泽社群高手论坛3 金湖县| 栖霞市| 吉安县| 武鸣县| 和静县| 正镶白旗| 安仁县| 金华市| 海宁市| 湾仔区| 丹江口市| 平江县| 巨鹿县| 武冈市| 健康| 同江市| 固镇县| 青岛市| 湘潭市| 夏津县| 青岛市| 龙井市| 凤庆县| 平陆县| 马公市| 南溪县| 许昌县| 珲春市| 泾川县| 文昌市| 锡林浩特市| 靖州| 四子王旗| 井研县| 尚志市| 汉沽区| 循化| 察隅县| 浮山县| 游戏| 勐海县| 梧州市| 山阴县| 瓮安县| 资溪县| 奉新县| 宁蒗| 万山特区| 孙吴县| 海南省| 申扎县| 衡水市| 宝丰县| 永胜县| 镇坪县| 温宿县| 潍坊市| 固镇县| 霞浦县| 四平市| 三江| 柳河县| 潞西市| 克什克腾旗| 锡林浩特市| 华阴市| 达拉特旗| 云龙县| 宁晋县| 铅山县| 乐安县| 双城市| 东城区| 石家庄市| 金门县| 南汇区| 伊宁县| 从化市| 惠州市| 邢台县| 定西市| 绥芬河市| 隆昌县| 囊谦县| 桑植县| 榆中县| 泰顺县| http://3g.flsigno888.com http://hteamr888.com http://gweatherl888.com http://hwaitr888.com http://m.gweightl888.com http://3g.flshareo888.com http://wap.gweekendl888.com http://m.flsiteo888.com http://3g.hsleepr888.com http://3g.hhiter888.com http://wap.hwinr888.com