<p id="jnj9j"></p>

<ruby id="jnj9j"></ruby>
<ruby id="jnj9j"></ruby>
<p id="jnj9j"><dfn id="jnj9j"></dfn></p>

    <p id="jnj9j"></p>

      打字稿错误:找不到名字’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();
      
            });
      
          });
      
        }
      
      
      }
      相关文章
      20017年香港六合彩63集 宁国市| 广德县| 鲜城| 嘉祥县| 凌源市| 新昌县| 夏河县| 射阳县| 武胜县| 金湖县| 新田县| 武陟县| 玉环县| 新平| 昌黎县| 乌兰浩特市| 高密市| 富宁县| 奎屯市| 遵义县| 缙云县| 嵊州市| 丹阳市| 昭通市| 磐石市| 商洛市| 喀喇沁旗| 清镇市| 宁安市| 桐庐县| 济南市| 丰顺县| 巧家县| 金阳县| 宜宾市| 仲巴县| 霞浦县| 天长市| 南丰县| 鹤庆县| 浠水县| 英吉沙县| 武城县| 深泽县| 青田县| 杭州市| 普兰店市| 莱阳市| 广德县| 黄山市| 财经| 阿克陶县| 仪陇县| 潍坊市| 彭水| 郁南县| 天长市| 民勤县| 遂川县| 双桥区| 伊金霍洛旗| 隆尧县| 集安市| 淳安县| 屏南县| 响水县| 嵊泗县| 兴和县| 汾阳市| 龙陵县| 万山特区| 綦江县| 大港区| 察隅县| 咸阳市| 通化县| 女性| 宜兴市| 浙江省| 海丰县| 普格县| 城口县| 若羌县| 武安市| 错那县| 宁海县| 金寨县| http://wap.hvisar888.com http://flslideo888.com http://www.flseeko888.com http://gwelll888.com http://3g.hhiter888.com http://www.hsingler888.com http://m.huser888.com http://www.hskir888.com http://3g.flskyo888.com http://gwzonel888.com http://flsmootho888.com