我創建了一個簡單的應用程序,可以使用@ ionic-native/photo-library從手機中選擇照片。現在我想調試它,打印一些控制檯日誌,檢查照片是否正確裝入:如何在離子應用程序上調試原生cordova插件?
private selectPhoto() {
this.photoLibrary.requestAuthorization().then(() => {
this.photoLibrary.getLibrary().subscribe({
next: library => {
library.forEach((libraryItem) => {
console.log(libraryItem) // i want to print it
})
},
error: err => {},
complete:() => { console.log('could not get photos'); }
})
})
.catch(err => console.log(err));
}
可惜的是,我收到一個錯誤:
Native: tried calling PhotoLibrary.requestAuthorization, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
,我讀了本地插件必須在設備上進行測試但如何從我的控制檯中的代碼獲取輸出?當我安裝apk時,我沒有任何調試信息。
問候
只需使用vscode-cordova擴展 – Bob