微信小程序?qū)崿F(xiàn)底部彈出框
微信小程序的底部彈出框,供大家參考,具體內(nèi)容如下
wxml
<!-- 彈出框 start --> <view class="dialog_screen" bindtap="hideModal" wx:if="{{showModalStatus}}"></view> <view animation="{{animationData}}" class="dialog_attr_box" wx:if="{{showModalStatus}}"> <view style='background:white;position: relative;overflow: hidden;'> <view class='dialog_title'>選擇系列</view> <view wx:for="{{list}}" wx:key="name" class='dialog_content'> <view class="{{item.status==0?'type_nor':'type_pre'}}" bindtap='typeClick' data-index='{{index}}'>{{item.txt}}</view> </view> </view> </view> <!-- 彈出框 end -->
wxss
/* dialog start */ .dialog_screen { width: 100%; height: 100%; position: fixed; top: 0; left: 0; background: #000; opacity: 0.2; overflow: hidden; z-index: 1000; color: #fff; } .dialog_attr_box { width: 100%; overflow: hidden; position: fixed; bottom: 0; left: 0; z-index: 2000; background: #fff; padding-top: 1px; } .dialog_title { font-size: 16px; height: 30px; display: flex; align-items: center; padding: 10px; background: #80cbc4; color: white; } .dialog_content { position: relative; float: left; padding: 10px 10px; width: 25%; box-sizing: border-box; } /* dialog end */
js
var postData = require('../../../data/StoreData.js'); var typeList = postData.postListData; Page({ data: { list: typeList }, onLoad: function(options) { var id = options.id; //頁(yè)面跳轉(zhuǎn)傳過(guò)來(lái)的值 //初始化默認(rèn)一部分?jǐn)?shù)據(jù)已選中 for (var i = 0; i < typeList.length; i++) { if (i % 2 == 0) { typeList[i].status = 0; } else { typeList[i].status = 1; } } this.setData({ list: typeList }); }, showModal: function() { // 顯示遮罩層 var animation = wx.createAnimation({ duration: 200, timingFunction: "linear", delay: 0 }) this.animation = animation animation.translateY(300).step() this.setData({ animationData: animation.export(), showModalStatus: true }) setTimeout(function() { animation.translateY(0).step() this.setData({ animationData: animation.export() }) }.bind(this), 200) }, hideModal: function() { // 隱藏遮罩層 var animation = wx.createAnimation({ duration: 200, timingFunction: "linear", delay: 0 }) this.animation = animation animation.translateY(300).step() this.setData({ animationData: animation.export(), }) setTimeout(function() { animation.translateY(0).step() this.setData({ animationData: animation.export(), showModalStatus: false }) }.bind(this), 200) }, typeClick: function(e) { var index = e.target.dataset.index; for (var i = 0; i < typeList.length; i++) { if (i == index) { var curStatus = typeList[i].status; if(curStatus == 0){ typeList[i].status = 1; }else{ typeList[i].status=0; } break; } } this.setData({ list: typeList }); } })
data
var list = [{ "id": 1, "txt": "AA" }, { "id": 2, "txt": "BB" }, { "id": 3, "txt": "CC" }, { "id": 4, "txt": "DD" }, { "id": 5, "txt": "EE" }, { "id": 6, "txt": "FF" }, { "id": 7, "txt": "RR" }, { "id": 8, "txt": "HH" }, { "id": 9, "txt": "KK" }, { "id": 10, "txt": "WW" } ] module.exports = { postListData: list }
為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開發(fā)教程》小編為大家精心整理的,希望喜歡。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
javascript中的prototype屬性使用說(shuō)明(函數(shù)功能擴(kuò)展)
一說(shuō)到prototype很多人可能第一個(gè)想到的是著名的prototype.js框架,當(dāng)然我們今天說(shuō)的不是它,而是Javascript中的prototype屬性,一般都被翻譯為“原型”。2010-08-08Javascript連接多個(gè)數(shù)組不用concat來(lái)解決
這篇文章主要介紹了不用concat解決Javascript連接多個(gè)數(shù)組,需要的朋友可以參考下2014-03-03詳解JS實(shí)現(xiàn)系統(tǒng)登錄頁(yè)的登錄和驗(yàn)證
這篇文章主要介紹了JS實(shí)現(xiàn)系統(tǒng)登錄頁(yè)的登錄和驗(yàn)證,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04一個(gè)簡(jiǎn)單但常用的javascript表格樣式_鼠標(biāo)劃過(guò)行變色 簡(jiǎn)潔實(shí)現(xiàn)
經(jīng)常性的會(huì)需要使用表格顯示一些東西,當(dāng)表格比較大的時(shí)候一眼望去腦袋可能會(huì)有些暈,經(jīng)常性的因?yàn)闆]看準(zhǔn)行而出現(xiàn)誤操作,一般解決辦法是交替行變行或者鼠標(biāo)劃過(guò)行變色2008-09-09bootstrap滾動(dòng)監(jiān)控器使用方法解析
這篇文章主要為大家詳細(xì)解析了bootstrap滾動(dòng)監(jiān)控器使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01