简体   繁体   English

锚标签下载在移动设备上不起作用

[英]Anchor tag download doesn't work on mobile

I'm creating a mobile app using Ionic Framework, AngularJs, and Html. 我正在使用Ionic Framework,AngularJs和HTML创建一个移动应用程序。 There's a page where a user needs to click on a <div> to download a wallpaper, when I'm trying to click the download it works when I'm on the web browser debug mode using the ionic serve but when I try to create the apk and test it in the mobile, it doesn't work. 有一个页面,用户需要单击<div>来下载墙纸,当我尝试单击下载时,当我使用ionic serve进入Web浏览器调试模式但尝试创建时,该下载将起作用apk并在移动设备中对其进行测试,它不起作用。 I have the following code on my html: 我的html上有以下代码:

<div class="dl-btn">
<a download="someFilename" href="img/download-wallpaper.jpg">
<img src="img/download.png" width="40%" height="auto" class="center">
</a>
</div>

The reason it works in the browser and not on devide is because the browser just opens the href link in a new tab which asks you to download the file. 它在浏览器中起作用而不是凭空运行的原因是因为浏览器只是在新选项卡中打开href链接,要求您下载文件。 In a mobile app, you don't really have the concept of a new tab since it's not a full browser. 在移动应用程序中,由于它不是完整的浏览器,因此您实际上没有新标签的概念。

You will have to use the file transfer plugin to download the file to a path on the user's device. 您将必须使用文件传输插件将文件下载到用户设备上的路径。

Check out the following section of the link and report back: 请查看链接的以下部分并进行报告:

https://github.com/apache/cordova-plugin-file-transfer#download https://github.com/apache/cordova-plugin-file-transfer#download

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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