当前位置:   article > 正文

vue自定义(uni-popup)_uni-popup.vue

uni-popup.vue

在这里插入图片描述

<template>
	<view>
		<uni-popup ref="popup" type="bottom">
			<view class="popup-content">
				<view>{{title}}</view>
				<input v-model="value" type="text">
				<view>
					<view class="btn-click" @click="handleConfirm">确定</view>
					<view class="btn-click" @click="handleCancel">取消</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		props: {
			title: {
				type: String,
				default: ''
			},
		},
		data() {
			return {
				value: null
			}
		},
		methods: {
			show() {
				this.$refs.popup.open('top')
			},
			handleCancel() {
				this.value = null;
				this.$emit('onClickCancel', 'cancel')
				this.$refs.popup.close();

			},
			handleConfirm() {
				this.$emit('onClickConfirm', this.value);
				this.value = null;
				this.$refs.popup.close();

			}
		}
	}
</script>

<style lang="scss">
	.popup-content {
		background-color: #fff;
		padding: 40rpx;
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;

		>view:nth-of-type(1) {
			font-size: 36rpx;
			font-weight: 800;
		}

		>input {
			margin-top: 30rpx;
			background-color: #eee;
			font-size: 40rpx;
			padding: 20rpx;
		}

		>view:nth-of-type(2) {
			display: flex;
			margin-top: 20rpx;

			>view {
				flex: 1;
				text-align: center;
				padding: 20rpx 0rpx;
				color: #fff;
				border-radius: 10rpx;
			}

			>view:nth-of-type(1) {
				margin-right: 10rpx;
				background-color: #376ec1;
			}

			>view:nth-of-type(2) {
				margin-left: 10rpx;
				background-color: #FA8888;
			}
		}


	}

	.btn-click:active {
		opacity: 0.5;
		transform: scale(0.95);
	}
</style>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
	import MSPopup from '@/components/ms-popup/ms-popup.vue'
	components: {
			MSPopup,
		},
<ms-popup ref='popup' title="测试标题" @onClickConfirm="confirm"></ms-popup>
this.$refs['popup'].show();
confirm(value){
	console.log(value)
	
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号