Skip to content

Instantly share code, notes, and snippets.

@Houserqu
Created February 22, 2019 06:24
Show Gist options
  • Save Houserqu/35867f0cb4f0f98fd7bc6ce82998d9d2 to your computer and use it in GitHub Desktop.
Save Houserqu/35867f0cb4f0f98fd7bc6ce82998d9d2 to your computer and use it in GitHub Desktop.
二维码生成组件-vue
// <script src="./resources/js/qrcode.min.js"></script>
// https://davidshimjs.github.io/qrcodejs/
Vue.component('qrcode', {
props: ['value', 'id'],
template: '<div id="id"></div>',
mounted: function () {
this.initQR()
},
methods: {
initQR: function () {
this.qrcode = new QRCode(document.getElementById("id"), { width: 140, height: 140 });
this.qrcode.makeCode(this.value);
}
}
})
@Houserqu
Copy link
Author

基于 qrcode.js 库

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment