感谢大家的回复~已经实现了~
思路:通过某些算法,得到一个二位数组,然后使用Graphics组件画出来。
我使用的算法是这个qrcode.js,测试了浏览器和native都可以使用。
相关代码:
var qrcode = new QRCode(-1, QRErrorCorrectLevel.H);
qrcode.addData('http://www.lihang.info');
qrcode.make();
var ctx = this.node.getComponent(cc.Graphics);
// compute tileW/tileH based on node width and height
var tileW = this.node.width / qrcode.getModuleCount();
var tileH = this.node.height / qrcode.getModuleCount();
// draw in the Graphics
for (var row = 0; row < qrcode.getModuleCount(); row++) {
for (var col = 0; col < qrcode.getModuleCount(); col++) {
// ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background;
if (qrcode.isDark(row, col)) {
ctx.fillColor = cc.Color.BLACK;
} else {
ctx.fillColor = cc.Color.WHITE;
}
var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW));
ctx.rect(Math.round(col * tileW), Math.round(row * tileH), w, h);
ctx.fill();
}
}

我也没有成功
后 mark ,顺便 拍个马屁 大佬NB