uniapp 下拉菜单 picker

模拟下拉下单
原样式示例:
在这里插入图片描述

1、第一种:修改为自己需要的样式及功能:

在这里插入图片描述
在这里插入图片描述

<view class="items select-box">
	<view class="items-text">是否已告知物业(必填)</view>
	<picker @change="bindPickerChange" :value="index" :range="array" class="picker-box" v-if="pickerShow">
		<input class="select-input" type="text" placeholder="请选择是否已告知物业" v-if="index == -1" disabled="disabled"></input>
		<view class="select-input" type="text" v-else>{{array[index]}}</view>
	</picker>
	<view class="icon-img">
		<!-- 下拉角标图片 -->
		<image src="../../static/img/select-icon.png"></image>
	</view>
</view>

data() {
	return {
		index: -1,
		array: ['是', '否'],
	}
},


methods: {
	// 下拉列表
	bindPickerChange: function(e) {
		console.log('picker发送选择改变,携带值为', e.detail.value)
		this.index = e.detail.value
	},
},

<style>
/* 下拉列表 start */
.select-box{
	position: relative;
}
.picker-box{
	width:100%;
	height: 88rpx;
	line-height: 88rpx;
	border-radius: 10rpx;
	box-sizing:border-box;
}
.select-input{
	width:100%;
	height: 88rpx;
	line-height: 88rpx;
	border-radius: 10rpx;
	border: 1rpx solid #BDBDBD;
	padding-left: 22rpx;
	box-sizing:border-box;
}
.icon-img{
	position: absolute;
	top: 84rpx;
	right: 18rpx;
	width: 18rpx;
	height: 18rpx;
}
.icon-img image{
	width:100%;
	height:100%;
}
/* 下拉列表 end */
</style>

2、第二种

在这里插入图片描述

<view class="other-item">
	<view>选择种类</view>
	<view class="right-box">
		<picker @change="bindPickerChange" :value="index" :range="array">
			<view v-if="index == -1">请选择种类</view>
			<view v-else>{{array[index]}}</view>
		</picker>
		<view class="right-icon">
			<image src="../../static/img/more.png"></image>
		</view>
	</view>
</view>


data() {
	return {
		index: -1,
		array: ['1', '2', '3'],
	}
},


methods: {
	// 下拉列表
	bindPickerChange: function(e) {
		console.log('picker发送选择改变,携带值为', e.detail.value)
		this.index = e.detail.value
	},
},

<style>
.other-item{
	font-size: 30rpx;
	color: #666666;
	padding-top: 12rpx;
	display: flex;
	justify-content:space-between;
	align-items: center;
	margin-bottom: 17rpx;
}
.right-box{
	display: flex;
	align-items: center;
}
.right-icon{
	width: 16rpx;
	height: 28rpx;
	margin-left: 24rpx;
}
.right-icon image{
	width: 100%;
	height: 100%;
}
</style>

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值