微信小程序select下拉框?qū)崿F(xiàn)源碼
這篇文章主要介紹了微信小程序select下拉框?qū)崿F(xiàn)源碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下

小程序中是沒有h5中的下拉 標(biāo)簽的 所以要實(shí)現(xiàn)下拉功能就必須自己動手寫拉,這里為了更清楚的顯示小程序?qū)蛹?就把源碼直接復(fù)制過來了
<view class='list-msg'>
<view class='list-msg1'>
<text>商品金額</text>
<text>¥99.00</text>
</view>
<!--下拉框 -->
<view class='list-msg2' bindtap='bindShowMsg'>
<text>{{tihuoWay}}</text>
<image style='height:20rpx;width:20rpx;' src='/images/down.png'></image>
</view>
<view class='list-msg1'>
<text>運(yùn)費(fèi)</text>
<text></text>免郵</view>
<view class='list-msg1'>
<text>實(shí)際付款</text>
<text style='color:red'>¥99.00</text>
</view>
<!-- 下拉需要顯示的列表 -->
<view class="select_box" wx:if="{{select}}">
<view class="select_one" bindtap="mySelect" data-name="重慶分店">重慶分店</view>
<view class="select_one" bindtap="mySelect" data-name="東莞南城分店">東莞南城分店</view>
<view class="select_one" bindtap="mySelect" data-name="東莞總店">東莞總店</view>
</view>
</view>
下面是js代碼
Page({
/**
* 頁面的初始數(shù)據(jù)
*/
data: {
select: false,
tihuoWay: '門店自提'
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面加載
*/
onLoad: function(options) {
},
bindShowMsg() {
this.setData({
select: !this.data.select
})
},
mySelect(e) {
var name = e.currentTarget.dataset.name this.setData({
tihuoWay: name,
select: false
})
},
/**
* 用戶點(diǎn)擊右上角分享
*/
onShareAppMessage: function() {
}
})
.list - msg {
padding: 0 20rpx;
background - color: #fff;
position: relative;
}
.list - msg1 {
height: 60rpx;
display: flex;
align - items: center;
justify - content: space - between;
}
.list - msg.list - msg2 {
height: 60rpx;
display: flex;
align - items: center;
justify - content: space - between;
border: 1px solid#ccc;
padding: 0 10rpx;
}
.select_box {
background - color: #eee;
padding: 0 10rpx;
width: 93 % ;
position: absolute;
top: 130rpx;
z - index: 1;
overflow: hidden;
animation: myfirst 0.5s;
}
@keyframes myfirst {
from {
height: 0rpx;
}
to {
height: 210rpx;
}
}
.select_one {
height: 60rpx;
line - height: 60rpx;
border - bottom: 1px solid#ccc;
}
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
跟我學(xué)習(xí)javascript的浮點(diǎn)數(shù)精度
跟我學(xué)習(xí)javascript的浮點(diǎn)數(shù)精度,帶大家真正的理解JavaScript的浮點(diǎn)數(shù),提醒大家當(dāng)心浮點(diǎn)運(yùn)算中的精度陷阱,需要的朋友可以參考下2015-11-11
使用Vite從零搭建前端項(xiàng)目的詳細(xì)過程
這篇文章主要介紹了使用Vite從零搭建前端項(xiàng)目的詳細(xì)過程,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-08-08
eval(function(p,a,c,k,e,d)系列解密javascript程序
在網(wǎng)上下載源代碼時,很可能發(fā)現(xiàn)代碼里的JS腳本看不懂,這是由于JS加密造成的。如果你發(fā)現(xiàn)JS是以eval(function(p,a,c,k,e,r){e=function(c)開頭的,看到這個頁面你就可以解決他2007-04-04
JavaScript ES5標(biāo)準(zhǔn)中新增的Array方法
這篇文章主要介紹了JavaScript ES5標(biāo)準(zhǔn)中新增的Array方法 的相關(guān)資料,需要的朋友可以參考下2016-06-06
有效的捕獲JavaScript焦點(diǎn)的方法小結(jié)
閱讀本文可理解并解決以下問題 設(shè)置元素可獲得焦點(diǎn)以監(jiān)聽鍵盤事件 某個元素明明設(shè)置了聚焦卻沒效果 聚焦時拋出異常的2009-10-10

