1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <template>
- <div id="qrcode">
- <el-row>
- <el-col :span="24" style="text-align:center">
- <canvas id="canvas"></canvas>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import QRCode from 'qrcode';
- export default {
- name: 'qrcode',
- props: {
- xm: { type: null },
- code: { type: null },
- type: { type: null },
- },
- components: {},
- data: () => ({}),
- created() {
- this.$nextTick(() => {
- this.initQrcode();
- });
- },
- computed: {
- newHeight: {
- get() {
- let height;
- if (this.utype === 'user') {
- height = window.screen.availHeight * 0.3 + 'px';
- } else {
- height = window.screen.availHeight * 0.6 + 'px';
- }
- let style = { height: height };
- return style;
- },
- },
- },
- methods: {
- async initQrcode() {
- await QRCode.toCanvas(document.getElementById('canvas'), this.code, {
- width: 300,
- margin: 0,
- color: { dark: '#ff4400' }, //{ dark: this.$route.query.type === '0' ? '#00ff14' : '#FF9900' }
- });
- },
- },
- };
- </script>
- <style lang="less" scoped></style>
|