uni搭配uView框架,uView框架弹出层,网址:https://www.uviewui.com/
<view class="qrcode" @click="open()">
<image src="/static/images/qrcode.png" mode="aspectFit">image>
view>
<u-popup :show="show" mask="true" mode="center">
<view>
<image src="../../static/images/close.png" mode="aspectFill" @click="close()" >image>
//这里面存放弹出的内容
view>
u-popup>
methods: {
open() {
this.show = true;
},
close() {
this.show = false;
}
}
<view class="qrcode" @click="open()">
<image :src="$common.image('/static/images/qrcode.png')" mode="aspectFit" class="qrcodeSmall">image>
view>
<template>
<view>
<u-popup :show="show" mask="true" mode="center" width="689rpx" height="689rpx">
//这里面放内容
//关闭按钮
<image src="/static/images/close.png" mode="aspectFill" @click="close()" >image>
u-popup>
view>
template>
<script>
export default {
name:"qrcode",
data() {
return {
show:false
};
},
methods:{
close() {
this.show = false;
},
}
}
script>
<style lang="scss">
style>
在需要使用的页面引入、注册、使用。
引入、注册:
//引入组件
<script>
import qrcode from '@/components/qrcode/qrcode.vue'
export default {
//注册组件
components: {
qrcode
},
data() {
return {
}
},
methods: {
// 二维码弹出层
open() {
this.$refs.qrcode.show = true
},
}
}
</script>
使用:
<view class="qrcode" @click="open()">
<image :src="$common.image('/static/images/qrcode.png')" mode="aspectFit" class="qrcodeSmall">image>
view>
<template>
<view class="content">
<qrcode ref="qrcode">qrcode>
view>
template>
ref的使用:
https://www.cnblogs.com/dianzan/p/12403353.html
弹出层:
https://www.uviewui.com/components/popup.html