ForgeComponents
en

Components

j-QRCode

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20

This component creates a QR code. It includes the QRCode library.


Configuration:

  • width {Number} a default image width (default: 128)
  • height {Number} a default image height (default: 128)
  • fg {String} a foreground color (default: #000000)
  • bg {String} a background color (default: #FFFFFF)
  • delay {Number} a small delay for code generating (default: 200)

How to generate QR Code?

var opt = {};
opt.text = 'https://www.totaljs.com';
// opt.width {Number}
// opt.height {Number}
// opt.fg {String}
// opt.bg {String}
opt.callback = function(base64) {
	console.log(base64);
};
SETTER('qrcode/create', opt);

Use it with <ui-component name="qrcode">. When the component is not loaded yet, jComponent downloads it on first use from the address in DEF.fallback (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

example.html
<ui-component name="qrcode" config="width:200;height:200"></ui-component>

<script>

	ON('ready', function() {
		var opt = {};
		opt.text = 'https://totaljs.com';
		opt.callback = function(base64) {
			var img = document.createElement('IMG');
			img.setAttribute('src', base64);
			document.body.append(img);
		};
		SETTER('qrcode/create', opt);
	});

</script>