微信小程序中定义好的几种picker选择器,不管是日期选择器还是地区选择器,或是其他的都有定死的样式和内容。
例如:
但是大多数开发程序的情况下还是需要自己写样式的,或是内容的。
例如:
wxml
<view class="free-dialog {{ showDialog ? 'free-dialog--show' : '' }}">
<ra<a href="/tag/dio/" target="_blank" class="keywords">dio</a>-group class='free-ra<a href="/tag/dio/" target="_blank" class="keywords">dio</a>s' bindchange="ra<a href="/tag/dio/" target="_blank" class="keywords">dio</a>Change">
<label class="free-ra<a href="/tag/dio/" target="_blank" class="keywords">dio</a>" bindtap="click" wx:for="{{items}}" wx:key="{{items}}" data-id="{{index}}" style="{{index==id?'background:#48c23d;color:#fff;':'background:#fff;color:#000;'}}">
<ra<a href="/tag/dio/" target="_blank" class="keywords">dio</a> value="{{item.name}}" name="{{item.value}}"></radio>
<label class="free-text">{{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,})
},})
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,})
},})