1 Star 0 Fork 0

周连利/vue2.x-some-components

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
el-qrcode.vue 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
周连利 提交于 2024-12-26 15:51 +08:00 . 更新二维码组件,支持配置预览开关
<template>
<div class="ep-qrcode-wrap">
<el-image :src="url" :preview-src-list="previewSrcList" :style="imgStyle"></el-image>
</div>
</template>
<script>
import QRCode from 'qrcode'
export default {
props: {
//二维码的值
value: {
type: String,
default: ""
},
//默认展示的尺寸
size: {
type: Number,
default: 200
},
//可否点击预览
preview: {
type: Boolean,
default: false
},
//预览后弹窗展示的尺寸
previewSize: {
type: Number,
default: 400
}
},
data() {
return {
url: "",//预览图地址
}
},
created(){
//将二维码转换成图片
QRCode.toDataURL(this.value, {
width: this.previewSize,
color: {
dark: "#000000",
light: "#ffffff",
},
errorCorrectionLevel: "M",//low, medium, quartile, high or L, M, Q, H
}, (err, url)=>{
if(err){
console.log(err)
return
}
//保存图片链接
this.url = url
})
},
computed: {
//默认的图片宽度
imgStyle(){
return {
width: this.size + 'px',
height: this.size + 'px'
}
},
//图片预览地址
previewSrcList(){
return this.preview? [this.url]: []
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/lianlizhou/vue2.x-some-components.git
git@gitee.com:lianlizhou/vue2.x-some-components.git
lianlizhou
vue2.x-some-components
vue2.x-some-components
master

搜索帮助