npm 模块 qr-image 允许使用 NodeJS 生成 QRCode,如下所示:
import qr from 'qr-image';
import fs from 'fs';
qr.image('https://google.com/search?q=hello%20world!', {type:'png'}).pipe(fs.createWriteStream('myqrcode.png'));
// the qrcode is saved to myqrcode.png
Android 支持一项名为 Wi-Fi QRCode Generation 的功能,该功能创建一个 QRCode,当在不同的设备上扫描时,无需输入密码即可连接到 Wi-Fi 。有没有办法用上面提到的 qr-image 包来实现这个?
我搜索了Google,没有找到任何有用的信息,并尝试使用诸如wifi://
之类的协议,但没有任何效果。
zxing wiki。简而言之,格式是WIFI:S:<SSID>;T:<WPA|WEP|>;P:<password>;;
import qr from 'qr-image';
import fs from 'fs';
qr.image('WIFI:S:MYSSID;T:WPA;P:"password";;', {type:'png'}).pipe(fs.createWriteStream('myqrcode.png'));