微信小程序select下拉框?qū)崿F(xiàn)效果

小程序中是沒(méi)有h5中的下拉 標(biāo)簽的 所以要實(shí)現(xiàn)下拉功能就必須自己動(dòng)手寫(xiě)拉
這里為了更清楚的顯示層級(jí) 就把源碼直接復(fù)制過(guò)來(lái)了
<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({
/**
* 頁(yè)面的初始數(shù)據(jù)
*/
data: {
select: false,
tihuoWay: '門(mén)店自提'
},
/**
* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載
*/
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;
}
以上所述是小編給大家介紹的微信小程序select下拉框?qū)崿F(xiàn)效果詳解整合,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
兩種常用的javascript數(shù)組去重方法思路及代碼
第一種是常規(guī)的方法:建一個(gè)新的數(shù)組存放結(jié)果,for循環(huán)中每次從原數(shù)組中取出一個(gè)元素,用indexOf查找新數(shù)組中是否有該元素,至于第二種詳細(xì)的看下本文哦2013-03-03
微信小程序+ECharts實(shí)現(xiàn)動(dòng)態(tài)刷新的過(guò)程記錄
這篇文章主要給大家介紹了關(guān)于微信小程序+ECharts實(shí)現(xiàn)動(dòng)態(tài)刷新的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-05-05
JS+CSS實(shí)現(xiàn)電子商務(wù)網(wǎng)站導(dǎo)航模板效果代碼
這篇文章主要介紹了JS+CSS實(shí)現(xiàn)電子商務(wù)網(wǎng)站導(dǎo)航模板效果代碼,涉及JavaScript結(jié)合css動(dòng)態(tài)操作頁(yè)面元素屬性的相關(guān)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-09-09
JavaScript canvas實(shí)現(xiàn)九宮格切圖效果
這篇文章主要為大家詳細(xì)介紹了JavaScript canvas實(shí)現(xiàn)九宮格切圖效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09
javascript html 靜態(tài)頁(yè)面?zhèn)鲄?shù)
靜態(tài)頁(yè)面中用js獲取頁(yè)面參數(shù)的一些屬性方法,具體的獲取參數(shù),可以搜索本站以前的一些文章。2009-04-04

