在ionic 3中使用文件打开器没有任何胜利

时间:2019-01-14 13:24:25

标签: ionic-framework

我从Ionic文档https://ionicframework.com/docs/native/file-opener/中阅读了文档

但是赢了,我尝试在android模拟器中使用这个插件,什么也没显示

这是我的html代码:

<ion-content padding class="background">
<div>
  <button ion-button (click)="openpdf()">pdf</button>
</div>

这是typeScript代码:

openpdf(){

this.fileOpener.open('assets/filepdf.pdf', 'application/pdf')
 .then(() => console.log('File is opened'))
 .catch(e => console.log('Error opening file', e));
 }

赢我点击按钮,什么也没发生!

2 个答案:

答案 0 :(得分:1)

在此PDF中选中此示例将被下载(FileTransfer pluign)并打开:

col_counter = 0
a,b,c = pd.Series(),pd.Series(),pd.Series()

for column in df.columns:
    if col_counter == 3:
        col_counter = 0

    if col_counter == 0:
        # set_trace()
        a = a.append(df[column]).reset_index(drop = True)
    elif col_counter == 1:
        b = b.append(df[column]).reset_index(drop = True)
    elif col_counter == 2:
        c = c.append(df[column]).reset_index(drop = True)

    col_counter +=1

df_neu = pd.DataFrame({"A":a, "B":b, "C":c})
print (df_neu)
           A    B    C
0  960189042    B  NaN
1  977655199  nan  1.0
2  961771966    A  NaN
3  955308022    C  1.0
4  933277976    A  1.0
5  991581392    A  1.0
6  964195250    A  1.0
7  969007327    B  1.0
8  973316485    A  NaN
9  976749175    A  NaN

答案 1 :(得分:0)

您确定资产/文件pdf.pdf中的文件正确吗?

通过使用例如警报组件,您可以看到错误消息,例如:文件丢失,访问被拒绝或其他问题(它很脏,但是可以在模拟器的设备上运行,而无需进行其他调试)

export class MyPage {

  constructor(public alertCtrl: AlertController) { }

openpdf(){

 this.fileOpener.open('assets/filepdf.pdf', 'application/pdf')
  .then(() => 
{
       console.log('File is open', e));

       const alert = this.alertCtrl.create({
           title: 'File is open',
           subTitle: "",
           buttons: ['OK']
       });
       alert.present();
     }
   )
  .catch(e => 
     {
       console.log('Error opening file', e));

       const alert = this.alertCtrl.create({
           title: 'Error',
           subTitle: e,
           buttons: ['OK']
       });
       alert.present();
     }

}

}