ionic2 調用 cordova非本地化native 插件方法

1,在項目中添加你的插件    ionic

cordova plugin add puginId|puginName|puginUrl|puginPath

2,查看插件clobbers標記spa

    打開項目目錄plugins\pluginName\plugin.xml插件

這裏要注意不是全部的,clobbers target 格式都是 "cordova.pluging.xxxx" 也有多是:"window.xxxxx"或直接"xxxxx"這裏要特別注意code

3,聲明 clobbers 標記 變量xml

    在須要調用插件的.ts文件中定義clobbers 標記 變量,以下:cordova

declare let cordova: any;
declare let windowSoftManager: any;

變量名稱要與clobbers target中第一個點前面的一致,這裏若是是"window",不須要定義,ionic已經爲咱們定義了,可使用(<any>window).xxxx.xxx(),直接調用相應方法blog

4,調用插件中的方法get

路徑要與clobbers target中保持一致io

相關文章
相關標籤/搜索