From d035c7bb6e258f55ca6e04dce7676855dd20eeeb Mon Sep 17 00:00:00 2001 From: scopewu Date: Tue, 5 Jan 2021 17:47:09 +0800 Subject: [PATCH] docs: add document. --- CHANGELOG.md | 6 ++++++ README-zh_cn.md | 7 +++++++ README.md | 7 +++++++ docs/index.html | 2 +- package.json | 2 +- src/index.js | 12 +++++++++++- 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f83996..96eaecc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [3.1.0] - 2020-12-20 + +### Feature + +- Add support margin for QRcode. + ## [3.0.0] - 2020-12-20 ### Feature diff --git a/README-zh_cn.md b/README-zh_cn.md index bad0455..9afee5a 100644 --- a/README-zh_cn.md +++ b/README-zh_cn.md @@ -85,6 +85,13 @@ new Vue({ 二维码大小。 +### margin + +- Type: `number` +- Default: `0` + +定义空白区的宽度应该是多少。 + ### renderAs - Type: `string` diff --git a/README.md b/README.md index 5d83219..c4c121f 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,13 @@ qrcode Error correction level (one of 'L', 'M', 'Q', 'H'). Know more, [wikipedia The size of qrcode element. +### margin + +- Type: `number` +- Default: `0` + +Define how much wide the quiet zone should be. + ### renderAs - Type: `string` diff --git a/docs/index.html b/docs/index.html index 918228b..f836a99 100644 --- a/docs/index.html +++ b/docs/index.html @@ -91,7 +91,7 @@

qrcode.vue

components: { QrcodeVue: QrcodeVue, }, - data() { + data: function () { return { value: 'https://example.com', size: 100, diff --git a/package.json b/package.json index b290684..b1356f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qrcode.vue", - "version": "3.0.1", + "version": "3.1.0", "description": "A Vue.js component to generate QRCode.", "main": "dist/qrcode.vue.js", "module": "dist/qrcode.vue.esm.js", diff --git a/src/index.js b/src/index.js index 94834f3..e64aea8 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,16 @@ import QRCode from 'qr.js/lib/QRCode' import ErrorCorrectLevel from 'qr.js/lib/ErrorCorrectLevel' +// Thanks the `qrcode.react` +const SUPPORTS_PATH2D = (function () { + try { + new Path2D().addPath(new Path2D()) + } catch (e) { + return false + } + return true +})() + /** * Encode UTF16 to UTF8. * See: http://jonisalonen.com/2012/from-utf-16-to-utf-8-in-javascript/ @@ -181,7 +191,7 @@ const QrcodeVue = { ctx.fillStyle = foreground - if (typeof Path2D === 'function') { + if (SUPPORTS_PATH2D) { ctx.fill(new Path2D(generatePath(cells, margin))) } else { cells.forEach(function (row, rdx) {