网页生成二维码使用qrcode.js,不过qrcode.min.js貌似有bug,我直接用了qrcode.js。
Extjs需要封装一个component:
Ext.define('Arim.view.account.QRCode', {
extend: 'Ext.Component',
xtype: 'qrcode',
imgsize:128,
maximgsize:547,
text:'空白',
colorDark : "#000000",
colorLight : "#ffffff",
onRender: function (t, eOpts) {
var me = this;
me.callParent(arguments);
if(!me.qrcode){
var size = me.imgsize>me.maximgsize?me.maximgsize:me.imgsize;
me.qrcode = new QRCode(me.getEl(),{
width:size,
height:size,
text:me.text,
colorDark:me.colorDark,
colorLight:me.colorLight
});
}
},
onDestroy: function () {
if (this.qrcode) {
this.qrcode.clear();
}
this.callParent(arguments);
}
})
然后就可以使用了。
Ext.create('Ext.window.Window',{
title: '二维码',
width: 340,
height: 360,
items: [{
xtype:'qrcode',
margin:15,
imgsize : 300,
text:'二维码内容'
}]
}).show();