cordova-plugin-file in Chrome: cordova is not defined

后端 未结 2 666
情书的邮戳
情书的邮戳 2021-02-20 03:31

I use cordova-plugin-file in my ionic app to download images and save to local.

When I run it in emulator or iphone, there is no error, but when I test it in Chrome, it

2条回答
  •  借酒劲吻你
    2021-02-20 04:29

    Cordova will not be available in the browser; only on your device.

    In your index.html you should have this script reference:

    
    
    

    As the note says, the script won't be available during the development. It will be replaced during the build process.

    You can try it yourself:

    cordova platform add android
    

    then

    cordova build
    

    and you should find under platforms\android\assets\www 2 js files: cordova.js and cordova_plugins.js.

    Another option is to add browser as platform:

    cordova platform add browser
    

    and the run it:

    cordova run browser
    

    but you might face a few troubles.

提交回复
热议问题