国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

微信小程序實現自定義picker選擇器彈窗內容

2019-11-19 13:31:38
字體:
來源:轉載
供稿:網友

微信小程序中定義好的幾種picker選擇器,不管是日期選擇器還是地區選擇器,或是其他的都有定死的樣式和內容。

例如:

但是大多數開發程序的情況下還是需要自己寫樣式的,或是內容的。

例如:

wxml

<view class="free-btns" style="margin-top: 10vh;background:none;">  <button class="free-btn" bindtap="toggleDialog">   選定國家:{{value}}  </button> </view> <view class="free-dialog {{ showDialog ? 'free-dialog--show' : '' }}">  <view class="free-dialog__mask" bindtap="toggleDialog" />  <view class="free-dialog__container">   <view style="padding: 5% 5% 15%;">    <form bindsubmit='submit' bindreset="reset">     <view bindtap='freetoBack' class="free-button free-dialog-reset">取消</view>     <view bindtap='freeBack' class="free-button free-dialog-submit">確定</view>     <radio-group class='free-radios' bindchange="radioChange">      <label class="free-radio" bindtap="click" wx:for="{{items}}" wx:key="{{items}}" data-id="{{index}}" style="{{index==id?'background:#48c23d;color:#fff;':'background:#fff;color:#000;'}}">       <radio value="{{item.name}}" name="{{item.value}}"></radio>       <label class="free-text">{{item.value}}</label>      </label>     </radio-group>    </form>   </view> </view></view>

css

.free-dialog__mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10; background: rgba(0, 0, 0, 0.7); display: none;}.free-dialog__container { position: fixed; left: 0; bottom: 0; width: 750rpx; background: white; transform: translateY(150%); transition: all 0.4s ease; z-index: 11;}.free-dialog--show .free-dialog__container { transform: translateY(0);}.free-dialog--show .free-dialog__mask { display: block;}/*模態框中的內容*/.free-button{ display: inline-block; width:50px; text-align: center; font-size:20px; color:#707070; margin-bottom:20px;}.free-dialog-submit{ float: right; color:#48c23d;}radio-group{ margin:10rpx 0rpx;}radio-group>label{ width:22.5%; display: inline-block; border:1px solid #ddd; padding:10px 0px; margin:0px 2px 2px;}radio-group label radio{ width:100%; z-index: 3; display: none;}.checked{ background:#48c23d; color:#fff;}radio-group label .free-text{ width:100%; text-align: center; display: inline-block;}

js

Page({ data: {  showDialog: false,  items: [   { name: '中國', value: '中國' },   { name: '美國', value: '美國' },   { name: '巴西', value: '巴西' },   { name: '日本', value: '日本' },   { name: '英國', value: '英國' },   { name: '法國', value: '法國' },   { name: '韓國', value: '韓國' },   { name: '俄羅斯', value: '俄羅斯' },] }, /*點擊變色*/ click:function(e){  var id = e.currentTarget.dataset.id  var that = this  that.setData({   id:id  }) }, onLoad: function (options) {  var that = this  that.setData({   value:'show'  }) }, radioChange: function (e) {  console.log('radio發生change事件,攜帶value值為:', e.detail.value)  var that = this  that.setData({   value: e.detail.value  })  console.log(this.data.value) }, toggleDialog() {  this.setData({   showDialog: !this.data.showDialog  }); }, freeBack:function(){  var that = this  if(this.data.value=='show'){   wx.showModal({    title: '提示',    content: '你沒有選擇任何內容',   })  }  that.setData({   showDialog: !this.data.showDialog  }) }, freetoBack: function () {  var that = this  wx.showModal({   title: '提示',   content: '你沒有選擇任何內容',  })  that.setData({   showDialog: !this.data.showDialog,   value:'show',   checked: false,  }) },})

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平果县| 金华市| 自贡市| 舒城县| 万全县| 墨竹工卡县| 理塘县| 镇雄县| 齐河县| 永修县| 韶关市| 蒲江县| 崇仁县| 玉树县| 蒲江县| 昆山市| 象州县| 莱州市| 阜阳市| 隆安县| 丹巴县| 凉城县| 泗水县| 图木舒克市| 栾川县| 察雅县| 留坝县| 兴义市| 合肥市| 松桃| 治多县| 兴文县| 仪征市| 佳木斯市| 万盛区| 濮阳市| 沂水县| 岳阳市| 县级市| 黑山县| 栾城县|