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程序库生成二维码 某天浏览网页发现了一个二维码的程序库.它的描述说他可以扫描二维码图像.我很感兴趣,想试试他是不是会有用.所以我就用了些方法扫描二维码图像来测试一下.结果 ...
随机推荐
- 0 vs工程添加sdk
配置64位 库目录:(VC++目录) 可选配置 VS SDK(如果报错缺少kernel32.lib) C:\Program Files (x86)\Microsoft SDKs\Windows\v7. ...
- CentOS 7.X 系统安装及优化
centos的演变 启动流程sysvinit 串行启动:一次一个,一个一个启动 并行启动:全部的一起启动 init优点 运行非常良好.主要依赖于shell脚本 init缺点 1.启动慢 2.容易夯住, ...
- linux下打包压缩和解压命令
.tar 压缩:tar cvf FileName.tar FileName 解压:tar xvf FileName.tar .gz解压1:gunzip FileName.gz解压2:gzip -d F ...
- Python/Jupyter Notebook以及可视化的运用
最近陆陆续续使用Jupyter Notebook和Python可视化做了一些小工具,用于提高开发效率. 这里将其归类总结一下,作为学习的记录.
- 为什么建议php字符串使用单引号而不是双引号
不少php提升效率的tip,都有提到字符串使用单引号,这是为什么呢? 因为在单引号中,php直接认为它里头包含的就是个字符串.而双引号时,php会检测里头是否包含变量.这样如果是纯粹的字符串的话,双引 ...
- web service 框架
WebService简介 Web Service技术, 能使得运行在不同机器上的不同应用无须借助附加的.专门的第三方软件或硬件, 就可相互交换数据或集成.依据Web Service规范实施的应用之间, ...
- Docker中运行Dockerfile时报错“cannot allocate memory”
今天运行Dockerfile脚本时报错了,现记录下来: Step / : RUN -bin/myagent symlink /proc/mounts /var/lib/docker/overlay/2 ...
- linux系统原子操作
一.概念 原子操作提供了指令原子执行,中间没有中断.就像原子被认为是不可分割颗粒一样,原子操作(atomic operation)是不可分割的操作. c语言中一个变量的自加1操作,看起来很简 ...
- LOJ2687 BOI2013 Vim 线头DP
传送门 多图警告!!! 一种很新奇的\(DP\),全网似乎只有一两篇题解-- 首先,序列中的一段\(e\)等价于在跳的过程中这一段\(e\)之后的一个字符必须要经过,并且在最后的答案中加上$2 \ti ...
- Codechef MGCHGYM Misha and Gym 容斥、背包、Splay
VJ传送门 简化题意:给定一个长度为\(N\)的数列,\(Q\)个操作: \(1\,x\,a\).将数列中第\(x\)个元素改为\(a\) \(2\,l\,r\).反转子序列\([l,r]\) \(3 ...