HTML代码:
相关JS代码:
生成二维码
* data-width={宽度}
* data-height={高度}
* data-url={链接}
* @param $ele
*/
var generatorQRCODE = function ($ele) {
$ele.hide();
var params = $ele.data();
if(!params['width'] || !params['height'] || !params['url']){
console.log('生成二维码参数错误');
return false;
}
var image = new Image();
var imageUrl = "http://pan.baidu.com/share/qrcode?w=" + params['width'] + "&h=" + params['height'] + "&url=" + params['url'] + "";
image.src = imageUrl;
$ele.attr('src',imageUrl);
$ele.show();
};
generatorQRCODE($("#qrcode"));