关于下载:如何让steeve生成的二维码:jquery-qrcode包可下载 | 珊瑚贝

How to make qr codes generated by steeve:jquery-qrcode package downloadable


我有一个 Meteor 项目,其中每个用户都有一个个人资料页面,并且他们有自己的二维码链接到该页面。我想使用 steeve:jquery-qrcode 为他们生成的 qr 代码以 jpg 或 png 格式(如果可能的话都可以下载)。

我将如何做到这一点? (即使其可从客户端下载)

目前我只是使用页面上的以下代码在用户页面上显示二维码:

1
2
3
4
5
6
7
8
9
<template name=”profile”>
 
    Username:   {{username}}<br />
    {{#with profile}}
        Profile name: {{firstName}} {{lastName}}
    {{/with}}
   
 
</template>

这是客户端上的JS:

1
2
3
4
Template.profile.onRendered(function () {
  console.log(this.data.qrUrl);
  $(‘#qrblock’).qrcode({text: this.data.profile.qrUrl});
});

编辑:使用 img 元素而不是 div 元素会更容易实现吗?

  • 您可以发布您的工作代码或发布您的链接吗?
  • 资本流星网


我引用了以下链接:将 Html5 画布元素下载为带有 Javascript 文件扩展名的图像

1
Download Drawing

将此链接放在您视图的任何位置。它应该将图像下载为 png 文件。

关于浏览器兼容性问题,IE 和 Safari 暂不支持下载属性。这是一个关于下载属性的链接。

  • 有没有办法让这个工作也适用于 jpg 和 pdf?因为我尝试过更改名称,但不起作用…
  • 实际上,仅更改下载文件名是行不通的。看看 developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/… 它说 toDataURL() 可以有两个参数:toDataURL(type, encoderOptions);


来源:https://www.codenong.com/34571373/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_8877.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?