Skip to content

Commit

Permalink
docs: add document.
Browse files Browse the repository at this point in the history
  • Loading branch information
scopewu committed Jan 5, 2021
1 parent 79dd441 commit d035c7b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [3.1.0] - 2020-12-20

### Feature

- Add support margin for QRcode.

## [3.0.0] - 2020-12-20

### Feature
Expand Down
7 changes: 7 additions & 0 deletions README-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ new Vue({

二维码大小。

### margin

- Type: `number`
- Default: `0`

定义空白区的宽度应该是多少。

### renderAs

- Type: `string`
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h1>qrcode.vue</h1>
components: {
QrcodeVue: QrcodeVue,
},
data() {
data: function () {
return {
value: 'https://example.com',
size: 100,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 11 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -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/
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit d035c7b

Please sign in to comment.