You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
844 B

3 days ago
  1. Vue.component("qr", {
  2. template: '<div ref="qr" v-show="this.value !== \'\'"></div>',
  3. name: 'qr',
  4. props: {
  5. value: [String, Number],
  6. width: {
  7. "type": Number,
  8. "default": function () {
  9. return 128;
  10. }
  11. }
  12. },
  13. watch: {
  14. value: {
  15. immediate: true,
  16. handler: function (value) {
  17. if (this.qrcode) {
  18. this.qrcode.makeCode(value + "");
  19. }
  20. }
  21. }
  22. },
  23. mounted: function () {
  24. this.qrcode = new QRCode(this.$refs.qr, {
  25. text: this.value + "",
  26. width: this.width,
  27. height: this.width
  28. });
  29. },
  30. methods: {
  31. handleChange: function (e) {
  32. this.$emit("change", this.checked, e);
  33. }
  34. }
  35. });