code.vue 838 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <div>
  3. <div class="nut-qrcode" id="qrcode">二维码位置</div>
  4. </div>
  5. </template>
  6. <script>
  7. import QRCode from './asset/js/code.js';
  8. export default {
  9. name: 'nut-qrcode',
  10. props: {
  11. QCWidth: {
  12. type: Number,
  13. default: 160,
  14. },
  15. QCHeight: {
  16. type: Number,
  17. default: 160,
  18. },
  19. content: {
  20. type: String,
  21. required: true,
  22. },
  23. fontColor: {
  24. type: String,
  25. default: '#000',
  26. },
  27. backColor: {
  28. type: String,
  29. default: '#fff',
  30. },
  31. },
  32. data() {
  33. return {};
  34. },
  35. mounted() {
  36. this.qrcode();
  37. },
  38. methods: {
  39. qrcode() {
  40. let qrcode = new QRCode('qrcode', {
  41. width: this.QCWidth,
  42. height: this.QCHeight, // 高度
  43. text: this.content, // 二维码内容
  44. colorDark: this.fontColor,
  45. colorLight: this.backColor,
  46. margin: 0,
  47. });
  48. },
  49. },
  50. };
  51. </script>
  52. <style lang="scss"></style>