code.vue 995 B

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