qrcodeed.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div id="qrcode" ref="qrcode"></div>
  3. </template>
  4. <script>
  5. import QRCode from 'qrcodejs2' // 引入qrcode
  6. export default {
  7. name: "qrcode",
  8. props: {
  9. field: Object,
  10. formData: {
  11. type: Object,
  12. default () {
  13. return {}
  14. }
  15. },
  16. readonly: {
  17. type: Boolean,
  18. default: false,
  19. }
  20. },
  21. methods: {
  22. qrcode() {
  23. let qrcode = new QRCode('qrcode', {
  24. width: 132,
  25. height: 132,
  26. // text: 'https://www.baidu.com', // 需要二维码跳转的地址
  27. //text: `http://localhost:1111/#/ziliao?id=${this.formData.id}`, // 这2
  28. // text: `http://192.168.2.99:1111/#/ziliao?id=${this.formData.id}`, // 2
  29. // text:`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0aecf99696061a3&redirect_uri=http%3A%2F%2F192.168.2.99%3A1111%2F%23%2Fziliao&response_type=code&scope=snsapi_base&state=67e9c2b4e83a4091be478807565fb623#wechat_redirect`,
  30. // text:`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0aecf99696061a3&redirect_uri=https%3A%2F%2Fwww.szjyxt.com%2F%23%2Fziliao&response_type=code&scope=snsapi_base&state=${this.formData.id}#wechat_redirect`,
  31. //text:`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0aecf99696061a3&redirect_uri=https%3A%2F%2Fwww.szjyxt.com%2F%23%2Fziliao&response_type=code&scope=snsapi_base&state=${this.formData.id}#wechat_redirect`,
  32. // text:`https://www.szjyxt.com/#/ziliao?id=${this.formData.id}`,
  33. // text: `http://localhost:1111/#/ziliao/${this.formData.id}`,
  34. // text: `http://192.168.2.99:1111/#/ziliao/${this.formData.id}`,
  35. colorDark: "#000000", //前景色
  36. colorLight: "#FFFFFF", //背景色
  37. correctLevel:QRCode.CorrectLevel.L,
  38. })
  39. },
  40. },
  41. mounted() {
  42. this.$nextTick(() => {
  43. setTimeout(() => {
  44. this.qrcode();
  45. }, 0)
  46. })
  47. },
  48. }
  49. </script>
  50. <style scoped>
  51. #qrcode {
  52. width: 100px;
  53. height: 100px;
  54. }
  55. </style>