加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

微信小程序实现自定义picker选择器弹窗内容

发布时间:2020-12-14 20:06:52 所属栏目:资源 来源:网络整理
导读:微信小程序中定义好的几种picker选择器,不管是日期选择器还是地区选择器,或是其他的都有定死的样式和内容。 例如: 但是大多数开发程序的情况下还是需要自己写样式的,或是内容的。 例如: wxml view class="free-dialog {{ showDialog ? 'free-dialog--sh

微信小程序中定义好的几种picker选择器,不管是日期选择器还是地区选择器,或是其他的都有定死的样式和内容。

例如:

但是大多数开发程序的情况下还是需要自己写样式的,或是内容的。

例如:

wxml

<view class="free-dialog {{ showDialog ? 'free-dialog--show' : '' }}">

 <radio-group class='free-radios' bindchange="radioChange"&gt;
  <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;'}}"&gt;
   <radio value="{{item.name}}" name="{{item.value}}"&gt;</radio>
   <label class="free-text"&gt;{{item.value}}</label>
  </label>
 </radio-group>
</form>

css

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

},/点击变色/
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: '提示',})
that.setData({
showDialog: !this.data.showDialog,value:'show',checked: false,})
},})

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读