PhoneGap on iOS with absolute path URLs for assets?

前端 未结 3 538
难免孤独
难免孤独 2020-12-05 18:11

Porting a web app to phoneGap on iOS, we have asset (and ajax) URLs that are absolute paths, e.g.:


We hav

3条回答
  •  醉梦人生
    2020-12-05 18:39

    One can get the path to the application in JavaScript by:

    cordova.file.applicationDirectory
    

    Since I'm on Android, it says: "file:///android_asset/" ...for example:

    var img_path = cordova.file.applicationDirectory + 'www/img/logo.png';
    

    Like this all resources would be found when cross-building for various platforms.

提交回复
热议问题