大佬教程收集整理的这篇文章主要介绍了打字稿错误:找不到名字’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插件,如@L_262_8@,@L_262_8@传输但仍然错误无法解决.
任何人都可以寻找它.
这里附有代码,我也不知道我哪里出错了..
import {Component} from '@angular/core'; import {NavController,TransferObject} from '@ionic-native/transfer'; import {FilE} from '@ionic-native/file'; declare let cordova: any; @Component({ SELEctor: 'page-about',buttons: ['Ok'] }); alertFailure.present(); }); }); } }
以上是大佬教程为你收集整理的打字稿错误:找不到名字’cordova’全部内容,希望文章能够帮你解决打字稿错误:找不到名字’cordova’所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。