node.js如何在terminal显示二维码?

《node.js如何在terminal显示二维码?》要点:
本文介绍了node.js如何在terminal显示二维码?,希望对您有用。如果有疑问,可以联系我们。

node.js如何在putty,xshell,cmd等终端显示二维码?

只要qrcode-terminal 模块就行了哦,如下:

$ npm install qrcode-terminal

适用系统:

  • OS X

  • Linux

  • Windows

使用方法 qrcode.js:

const qrcode = require('qrcode-terminal')

var text = 'QRCode Terminal Edition';  //https://login.weixin.qq.com/qrcode/4ZtmDT6OPg==

qrcode.generate(text);
//qrcode.setErrorLevel('Q'); 自定义错误级别,默认是L
qrcode.generate(text, {small: false});

//可以有回调函数
qrcode.generate(text, function (qrcode) {
       console.log(qrcode);
});
//也可以结合使用
qrcode.generate(text, {small: true},  function (qrcode) {
       console.log(qrcode);
});

示例:

运行 $ node qrcode.js 

生成一个二维码。

node.js如何在terminal显示二维码?

相关文章

这篇文章主要介绍“基于nodejs的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...