QRCode_wev8.js
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
define(['mUtil', "Component"],function(mUtil, Component) {
var QRCode = function(options) {
Component.super(this, options);
this.type = "QRCode";
this.tpl = this.type + "_html";
this.css = this.type + "_css";
var vm = this.viewModel = {
content : "",
width : 256,
logo : "",
logoWidth : 40,
logoHeight : 40
};
this.mounted = function(){
if (!vm.content) return;
var $comp = this.$el.children(".wev-comp-" + this.type);
require(["qrcode"], function () {
$comp.html("").qrcode({
render: "canvas", //设置渲染方式,有table和canvas,使用canvas方式渲染性能相对来说比较好
text: vm.content,
width: vm.width, //二维码的宽度
height: vm.width, //二维码的高度
src: vm.logo, //二维码中间的图片
imgWidth: vm.logoWidth, //二维码图片的宽度
imgHeight: vm.logoHeight //二维码图片的高度
});
});
};
};
return Component.init(QRCode);
});