标签: fileopener2

android 和 ios 上的文件打开器 2 plugin_not_installed 错误 ionic 2 phonegap

尝试从 ionic 2 应用程序中的 url 打开 pdf 文件打开器 2 插件不起作用

执行的步骤: 1. 生成的应用程序使用:

ionic start fileopener blank --v2
Run Code Online (Sandbox Code Playgroud)

2.新增文件开启器:

sudo cordova plugin add cordova-plugin-file-opener2
Run Code Online (Sandbox Code Playgroud)
  1. 保存在项目中

sudo npm install --save @ionic-native/file-opener

家.ts

import { Component } from '@angular/core';
import { FileOpener } from '@ionic-native/file-opener';

@Component({
 selector: 'page-home',
 template: ` <ion-content>
               <button ion-button (click)="viewPdf()">Download pdf</button>
              </ion-content> 
             `
})

export class HomePage {

 constructor(private fileOpener: FileOpener) { }

 viewPdf(path) {
   this.fileOpener.open('assets/my.pdf', 'application/pdf')
 .then(() => alert('File is opened'))
 .catch(e =>alert(e));

 }
}
Run Code Online (Sandbox Code Playgroud)

app.module.ts

import …
Run Code Online (Sandbox Code Playgroud)

cordova-plugins ionic2 fileopener2 phonegap

5
推荐指数
0
解决办法
714
查看次数

标签 统计

cordova-plugins ×1

fileopener2 ×1

ionic2 ×1

phonegap ×1