以下是将文本转换为qr代码的示例。
var QRCode = require('qrcode');
var express = require('express');
var connect = express();
connect.get('/', function(req, res){
res.writeHead(200, { 'Content-Type': 'text/html' });
var sometext='hi my name is saurav ghadai';
// QRCode.QRCodeDraw.color.dark = '#d4d4d4';
QRCode.toDataURL(sometext, function (err, url) {
if (err) console.log('error: ' + err)
res.end("<!DOCTYPE html/><html><head><title>node-qrcode</title></head><body><img src='" + url + "'/></body></html>");
});
});
connect.listen(3030);
console.log('test server started on port 3030');
像这样我们如何为json对象创建qr代码?