qrcode.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <div id="qrcode">
  3. <el-row>
  4. <el-col :span="24" style="text-align:center">
  5. <canvas id="canvas"></canvas>
  6. </el-col>
  7. </el-row>
  8. </div>
  9. </template>
  10. <script>
  11. import QRCode from 'qrcode';
  12. export default {
  13. name: 'qrcode',
  14. props: {
  15. xm: { type: null },
  16. code: { type: null },
  17. type: { type: null },
  18. },
  19. components: {},
  20. data: () => ({}),
  21. created() {
  22. this.$nextTick(() => {
  23. this.initQrcode();
  24. });
  25. },
  26. computed: {
  27. newHeight: {
  28. get() {
  29. let height;
  30. if (this.utype === 'user') {
  31. height = window.screen.availHeight * 0.3 + 'px';
  32. } else {
  33. height = window.screen.availHeight * 0.6 + 'px';
  34. }
  35. let style = { height: height };
  36. return style;
  37. },
  38. },
  39. },
  40. methods: {
  41. async initQrcode() {
  42. await QRCode.toCanvas(document.getElementById('canvas'), this.code, {
  43. width: 300,
  44. margin: 0,
  45. color: { dark: '#ff4400' }, //{ dark: this.$route.query.type === '0' ? '#00ff14' : '#FF9900' }
  46. });
  47. },
  48. },
  49. };
  50. </script>
  51. <style lang="less" scoped></style>