简体   繁体   中英

How to display an image in a Meteor Cordova app on Android?

As it is shown in this screenshot I can access an image from Chrome desktop but not by in Xwalk. 在此处输入图片说明

However, the asset is present in assets/www/application/app and in .meteor/local/build/programs/web.cordova/app

The actual path of the image is generated by adding http://localhost:12752/local-filesystem/ before the file path as stated in the docs .

You should very probably put your static assets like such image in the [root]/public/ special folder of your Meteor project:

  • public

All files inside a top-level directory called public/ are served as-is to the client. When referencing these assets, do not include public/ in the URL, write the URL as if they were all in the top level. For example, reference public/bg.png as <img src='/bg.png' /> . This is the best place for favicon.ico , robots.txt , and similar files.

The page you refer to is about accessing files on the device storage (typically once a photo has been taken through a camera plugin), not your app static files:

[…] You can use this to convert URLs received from plugins like cordova-plugin-file and cordova-plugin-camera for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM