需求模仿支付模态框

<template>
	<view class="modalBg">
		<view class="modal_view">
			<view>
				请输入密码!
			</view>
			<view class="password">
				<view class="flex">
					<view class="password_num flex" v-for="(item,index) in miney_list">
						<view class="flex" v-if="item.id == index">
							<view v-for="(res,i) in money_input.length" v-show="i == index">
								<view class="miney_data"></view>
							</view>
						</view>
					</view>
				</view>
				<input v-model="money_input" maxlength="6" type="number" value="123" @input="input_num">
			</view>
		</view>
	</view>
</template>

<script>
	export default {
	
		data() {
			return {
				miney_list: [
					{id: 0,name: ''},
					{id: 1,name: ''},
					{id: 2,name: ''},
					{id: 3,name: ''},
					{id: 4,name: ''},
					{id: 5,name: ''},
				],
				money_input: '',
			};
		},
		created() {
			
		},
		methods: {
			// --------------------------------------------- input框事件
			input_num() {
				const that = this
				console.log(that.money_input.length)
				that.miney_list.forEach((item, index) => {
					for (var i = 0; i < that.money_input.length; i++) {
						if (i == index) {
							that.miney_list[index].name = '*'
						}
					}
				})
			}
		}
	}
</script>

<style scoped>
	.modalBg {
		width: 100vw;
		height: 100vh;
		position: absolute;
		top: 0;
		background-color: rgba(0, 0, 0, 0.4);
		z-index: 9999;
		display: flex;
		align-items: center;
		justify-content: center;
		overflow: hidden;
	}

	.modal_view {
		width: 70%;
		margin: 0 auto;
		background-color: #FFFFFF;
		padding: 22rpx 3%;
		box-sizing: border-box;
		border-radius: 20rpx;
		/* position: fixed;
	bottom: 0; */
	}
.flex{
	display: flex;
	align-items: center;
}
	.password {
		width: 100%;
		height: 66rpx;
		position: relative;
		margin: 22rpx 0;
	}

	.password_num {
		flex: 1;
		height: 65rpx;
		line-height: 65rpx;
		text-align: center;
		border: 2rpx solid #F2F2F2;
		justify-content: center;
	}

	.miney_data {
		width: 20rpx;
		height: 20rpx;
		background-color: #000000;
		border-radius: 50%;
	}

	.password input {
		width: 100%;
		height: 100%;
		position: absolute;
		top: 0;
		left: 0;
		opacity: 0;
	}
</style>

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐