Angular生成二维码
Installation - Angular 5+, Ionic
NPM
npm install angularx-qrcode --save
Yarn
yarn add angularx-qrcode
Installation - Angular 4
NPM
npm install angularx-qrcode@1.0.2 --save
Yarn
yarn add angularx-qrcode@1.0.2
Basic Usage
Import the module and add it to your imports section in your main AppModule (file: app.module.ts)
// all your imports
import { QRCodeModule } from 'angularx-qrcode';
@NgModule({
declarations: [
AppComponent
],
imports: [
QRCodeModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Examples
Generate a QR Code from a string (directive only)
Now that Angular/Ionic knows about our QR Code module, we can invoke it from our template with a directive. If we use a simple text-string, we need no additional code in our controller.
<qrcode [qrdata]="'Your QR code data string'" [size]="256" [level]="'M'"></qrcode>
Create a QR Code from a variable in your controller
In addition to our <qrcode>-directive in example.html, we add two lines of code to our controller example.ts.
// example.ts:
export class QRCodeComponent {
public angularxQrCode: string = '';
// assign a value anywhere in/below your constructor
this.myAngularxQrCode = 'Your QR code data string';
}
// example.html:
<qrcode [qrdata]="myAngularxQrCode" [size]="256" [level]="'M'"></qrcode>
Parameters
| Attribute | Type | Default | Description |
|---|---|---|---|
| allowEmptyString | Boolean | false | Allow empty string |
| colorlight | String | '#ffffff' | Dark color |
| colordark | String | '#000000' | Light Color |
| level | String | 'M' | QR Correction level ('L', 'M', 'Q', 'H') |
| qrdata | String | '' | String to encode |
| size | Number | 256 | Height / Width (any value) |
| usesvg | Boolean | false | SVG Output |
Note
Depending on the size (amoutn of data) of the qrdata to encode, a minimum size might be required.
git地址:https://github.com/Cordobo/angularx-qrcode
Angular生成二维码的更多相关文章
- 六、angular 生成二维码
首先需要安装angular-qrcode : bower install monospaced/angular-qrcode npm install angular-qrcode 如何使用? 在相应的 ...
- JavaScript的学习--生成二维码
有一些耗cpu的计算,完全可以在客户端上计算,比如生成二维码. qrcode其实是通过计算,然后使用jquery实现图形渲染和画图.支持canvas和table两种方式生成我们所需的二维码. 具体用法 ...
- Javascript生成二维码(QR)
网络上已经有非常多的二维码编码和解码工具和代码,很多都是服务器端的,也就是说需要一台服务器才能提供二维码的生成.本着对服务器性能的考虑,这种小事情都让服务器去做,感觉对不住服务器,尤其是对于大流量的网 ...
- 使用jquery.qrcode生成二维码(转)
jQuery 的 qrcode 插件就可以在浏览器端生成二维码图片. 这个插件的使用非常简单: 1.首先在页面中加入jquery库文件和qrcode插件. <script type=" ...
- iOS 生成二维码
首先先下载生成二维码的支持文件 libqrencode 添加依赖库 CoreGraphics.framework. QuartzCore.framework.AVFoundation.framewor ...
- QR code 扩展生成二维码
include './phpqrcode/phpqrcode.php'; //引入QR库 QRcode::png("leo", 'qrcode.png', 'L', 10); ...
- Python 创建本地服务器环境生成二维码
一. 需求 公司要做一个H5手机端适配页面,因技术问题所以H5是外包的,每次前端给我们源码,我们把源码传到服务器让其他人访问看是否存在bug,这个不是很麻烦吗?有人说,可以让前端在他们的服务器上先托管 ...
- C#通过第三方组件生成二维码(QR Code)和条形码(Bar Code)
用C#如何生成二维码,我们可以通过现有的第三方dll直接来实现,下面列出几种不同的生成方法: 1):通过QrCodeNet(Gma.QrCodeNet.Encoding.dll)来实现 1.1):首先 ...
- 使用Spire.Barcode程序库生成二维码
使用Spire.Barcode程序库生成二维码 某天浏览网页发现了一个二维码的程序库.它的描述说他可以扫描二维码图像.我很感兴趣,想试试他是不是会有用.所以我就用了些方法扫描二维码图像来测试一下.结果 ...
随机推荐
- UCML 参与者关键 与依赖关联外键
- ORA-245: In RAC environment from 11.2 onwards Backup Or Snapshot controlfile needs to be in shared location (Doc ID 1472171.1)
巡检时遇到错误如下: alert日志: Wed Dec 19 01:00:29 2018Errors in file /oracle/base/diag/rdbms/usap/usap1/trace/ ...
- mybatis collection使用注意
背景 今天我在使用collection时候,出现数据库有两条数据,但是却返回一条,在复制这条数据到四条后,依然返回一条 分析 这四条数据,数据库的每个字段值完全相同,所以估计是当成一条处理了 如果随便 ...
- java语言基础1问题汇总
1.一个Java类文件中真的只能有一个公有类吗? 程序实验: public class test1 { public static void main( String args[] ){ } publ ...
- SkylineGlobe 6.6 三维地图上实现自定义右键菜单示例代码
1.OnRButtonDown.htm <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ...
- 复习整理9:SpringMVC应用以及源码解析
一:SpringMVC是什么 SpringMVC只是Spring的一个子框架,作用学过Struts2的应该很好理解,他们都是MVC的框架.学他就是用来代替Struts2的,那么为什么不用Struts2 ...
- Luogu1514 NOIP2010 引水入城 BFS、贪心
传送门 NOIP的题目都难以写精简题意 考虑最上面一排的某一个点对最下面一排的影响是什么样的,不难发现必须要是一段连续区间才能够符合题意. 如果不是一段连续区间,意味着中间某一段没有被覆盖的部分比周围 ...
- 让IIS7和IIS6识别PUT和DELETE请求
项目组最近需要开展自动化测试,针对老的Aspx页面,这个做自动化测试的成本太高,于是我们想从老代码中封装一些ashx的Restful服务出来,Restful我们使用HTTP的GET.POST.PUT. ...
- Scala学习(七)---包和引入
包和引入 摘要: 在本篇中,你将会了解到Scala中的包和引入语句是如何工作的.相比Java不论是包还是引入都更加符合常规,也更灵活一些.本篇的要点包括: 1. 包也可以像内部类那样嵌套 2. 包路径 ...
- .NetCore实践篇:成功解决分布式监控ZipKin聚合依赖问题(三)
前言 读本篇文章之前,可以先读前两篇文章.为了照顾没看过的朋友,我也会稍作复习. 思考大纲: .Net架构篇:思考如何设计一款实用的分布式监控系统? 实践篇一:.NetCore实践篇:分布式监控客户端 ...