如何用vue+element-ui生成二维码

1.安装qrcode
element-ui 的使用官网添加链接描述

npm install  qrcodejs2  --save

2.页面引入

<template>
	<div>
			<el-button type="primary" @click="qrCode()" style="margin-left: 20px">生成二维码</el-button>
			<-- 弹窗提示-->
			<el-dialog title="支付" :visible.sync="dialogVisible" width="20%">
            <div id="qrcode"></div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
            </span>
        </el-dialog>
	</div>
</template>
<script>
		import QRCode from 'qrcodejs2'
		
		export default{
				data(){
					return {
						dialogVisible: false,
					}
				},
				methos:{
					qrCode() {
                this.dialogVisible = true;
                console.log(this.radio,this.radio1)
                this.$nextTick(function () {
                    document.getElementById("qrcode").innerHTML = "";
                    let qrcode = new QRCode("qrcode", {
                        width: 150,
                        height: 150,
                        text: "二维码内容",
                        colorDark: "#109dff",
                        colorLight: "#d9d9d9"
                    });
                });
            }
			}
		}
</script>

如何用vue+element-ui生成二维码_第1张图片

你可能感兴趣的:(vue)