diggingdata / yii2-kjua
使用 kjua 库显示 QRCode 的 Yii2 小部件
0.0.3
2023-07-18 11:39 UTC
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-18 14:19:11 UTC
README
本扩展为 Yii 框架 2.0 提供了一个 kjua QR Code 小部件。
kjua 库由 github/lrsjng 提供。
安装
安装此扩展的首选方法是使用 composer。
运行以下命令之一:
php composer.phar require --prefer-dist diggindata/yii2-kjua
或者添加
"diggindata/yii2-kjua": "@dev"
到您的 composer.json 的 require 部分,然后运行 composer update
。
用法
- 在视图文件中包含 QRCode 小部件
<?php
use diggindata\kjua\QrCodeWidget;
- 设置一些属性
<?php
$attributes = [
'label' => 'My Label',
'mode' => 'label',
'fill' => 'navy',
'text' => 'Good morning',
'rounded' => 50,
'ecLevel' => 'M',
'crisp' => false,
'mSize' => 20,
'options'=>['style'=>'display:inline']
];
- 显示 QRCode
<?= QrCodeWidget::widget($attributes); ?>
可用的属性列表描述如下:https://larsjung.de/kjua/。
在那个页面上还有一个链接到可用的演示页面。
属性列表
// render method: 'canvas', 'image' or 'svg'
render: 'image',
// render pixel-perfect lines
crisp: true,
// minimum version: 1..40
minVersion: 1,
// error correction level: 'L', 'M', 'Q' or 'H'
ecLevel: 'L',
// size in pixel
size: 200,
// pixel-ratio, null for devicePixelRatio
ratio: null,
// code color
fill: '#333',
// background color
back: '#fff',
// content
text: 'no text',
// roundend corners in pc: 0..100
rounded: 0,
// quiet zone in modules
quiet: 0,
// modes: 'plain', 'label' or 'image'
mode: 'plain',
// label/image size and pos in pc: 0..100
mSize: 30,
mPosX: 50,
mPosY: 50,
// label
label: 'no label',
fontname: 'sans',
fontcolor: '#333',
// image element
image: null