1.先npm装包
npm i qrcanvas
2.在模块中用import导入
import { qrcanvas } from "qrcanvas";
3.html
<div id="qrcode"></div>
4.在mounted生命周期钩子中使用
this.$nextTick(() => {
const canvas = qrcanvas({
data: "hello, world"
});
document.getElementById("qrcode").appendChild(canvas);
});
}
就可以在页面上生成二维码了 data参数中可放入需要跳转的链接