uni-app 组件使用 底部弹框

6 篇文章 0 订阅
5 篇文章 1 订阅

 

<template>
	<view>
		<view class="cover_screen" @click="hideBuyModal" v-if="showModalStatus"></view>
		<view class="buy_box" v-if="showModalStatus">
			<text class="title">{{title}}</text>
			<text class="newdetaildivider"></text>
			<text class="title" @tap="toCarmea">拍照</text>
			<text class="newdetaildivider"></text>
			<text class="title" @tap="toPhoto">相册</text>
			<text class="newdetaildivider"></text>
			<text class="title" @tap="primary">取消</text>
		</view>
	</view>

</template>

<script>
	export default {
		props:{
			isShowImgTitle:{
				type:Boolean,
				value:false
			},
			title:{
				type:String,
				value:'上传头像'
			}
		},
		data() {
			return {
				showModalStatus: false
			}
		},
		methods: {
			show(){
				this.showModalStatus = true
			},
			hide(){
				this.showModalStatus = false
			},
			hideBuyModal:function(){
				this.hide()
			},
			toCarmea:function(){
				console.log("~~~")
				this.$emit('toCarmea')
			},
			toPhoto:function(){
				console.log("~~~")
				
				this.$emit('toPhoto')
			},
			primary:function(){
				console.log("~~~")
				this.$emit('primary')
			}
			
		}
	}
</script>

<style>
	
	.buy_box {
	  width: 100%;
	  box-sizing: border-box;
	  position: fixed;
	  bottom: 0;
	  left: 0;
	  z-index: 2000;
	  background: #fff;
	  overflow: hidden;
	  display: flex;
	  flex-direction: column;
	}
	
	.newdetaildivider {
	  height: 1px;
	  background: #eaeaea;
	  display: block;
	}
	
	.title {
	  display: flex;
	  height: 99rpx;
	  font-size: 36rpx;
	  text-align: center;
	  align-items: center;
	  justify-content: center;
	}
	
	.titleImg {
	  flex-direction: column;
	  display: flex;
	  background-color: #eeeeee;
	}
	
	.titleImg text{
	  margin-top: 12rpx;
	  display: flex;
	  font-size: 36rpx;
	  text-align: center;
	  align-items: center;
	  justify-content: center;
	}
	
	.imgs {
	  margin-top: 12rpx;
	  display: flex;
	  justify-content: space-between;
	  margin-left: 30rpx;
	  margin-right: 30rpx;
	  margin-bottom: 12rpx;
	}
	
	.cover_screen {
	  width: 100%;
	  height: 100%;
	  position: fixed;
	  top: 0;
	  left: 0;
	  background: #000;
	  opacity: 0.2;
	  overflow: hidden;
	  z-index: 1000;
	  color: #fff;
	}
</style>

 

组件使用-以及事件回调

<vip-chooseImg ref="chooseImg" :title="title" :isShowImgTitle="true" v-on:toCarmea="toCarmea" v-on:toPhoto="toPhoto"
		 v-on:primary="primary"></vip-chooseImg>

回调事件

primary() {
	console.log('关闭弹框')
	this.$refs.chooseImg.hide()
},
//打开相机
toCarmea() {
	console.log('调用打开相机方法')
	this.$refs.chooseImg.hide()
},
toPhoto() {
//打开相册
}

 

  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值