微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

extjs + qrcode 实现二维码功能

    网页生成二维码使用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();

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐