toast.vue 1.64 KB
<template>
	<view>
		<div style="position: relative;">
			<slot></slot>
			<div class="toast" v-show="toastShow">
				<div class="toastContent">
					<div class="arrow"></div>
					<span class="typeBox" v-for="item in typeArr" @tap="itemClick(item.key)">{{item.name}}</span>
				</div>
			</div>
		</div>
		<div class="dialog"  v-if="toastShow" @tap="$emit('update:toastShow', false)"></div>
	</view>
</template>

<script>
	export default{
		data() {
			return {
			}
		},
		props: {
			toastShow:{
				type:Boolean,
				default:false
			},
			typeArr: {
				type: Array,
				default:function(){
					return [{
						name:"**",
						key:""
					}]
				} 
			},
		},
		watch: {
			toastShow(newValue, oldValue) {
			}
		},
		methods: {
			itemClick(key) {
				this.$emit('update:toastShow',false)
				this.$emit('handleChange',key);
			}
		},
	}
</script>

<style>
	.toast{
		position: absolute;
		top: 36px;
		left: 12px;
		z-index: 1001;
		box-shadow:0px 3.62upx 7.24upx 0px rgba(0,0,0,0.5);
	}
	.toastContent{
		position: relative;
		padding: 0 10.86upx;
		background: #FFFFFF;
		border-radius:7.24upx ;
	}
	.dialog{
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 1000;
		background: rgba(0,0,0,0.3);
	}
	.arrow{
		border: 9.06upx solid;
		width: 0;
		height: 0;
		border-color: transparent transparent #FFFFFF transparent;
		 position: absolute;
		 top: -18.11upx;
		left: 25.36upx;
	}
	.typeBox{
		padding: 19.92upx;
		border-bottom: 1px solid #DBDBDB;
		color: #000000;
		font-size:25.37upx;
		display: block;
		    line-height: normal;
	}
	.typeBox:last-child{
		border-bottom: none;
	}
	.typeBox:active{
		color: #C8C7CC;
	}
</style>