首页 >> js开发 >> js微信小程序如何实现radio单选框单击打勾和取消js大全
js微信小程序如何实现radio单选框单击打勾和取消js大全
发布时间: 2021年1月13日 | 浏览:
| 分类:js开发
前端使用input 来写radio,小程序使用radio标签 也可以使用 单标签1.自定义radio样式、wx默认的是真的丑
/* 单选框样式 */
/* 初始样式 */
radio .wx-radio-input{
width: 32rpx;
height: 32rpx;
border-radius: 0
}
/* 选中后的 背景样式 ( 背景 边框 ) */
radio .wx-radio-input.wx-radio-input-checked{
width: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
background:white!important;
}
/* 选中后的 对勾样式
*/
radio .wx-radio-input.wx-radio-input-checked::before{
width: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
line-height: 32rpx;
text-align: center;
font-size:36rpx; /* 对勾大小 */
color:black; /* 对勾颜色
*/
background: white;
transform:translate(-50%, -50%) scale(1);
-webkit-transform:translate(-50%, -50%) scale(1);
}
/* 单选框样式 */
/* 初始样式 */
radio .wx-radio-input{
width: 32rpx;
height: 32rpx;
border-radius: 0
}
/* 选中后的 背景样式 ( 背景 边框 ) */
radio .wx-radio-input.wx-radio-input-checked{
width: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
background:white!important;
}
/* 选中后的 对勾样式
*/
radio .wx-radio-input.wx-radio-input-checked::before{
width: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
line-height: 32rpx;
text-align: center;
font-size:36rpx; /* 对勾大小 */
color:black; /* 对勾颜色
*/
background: white;
transform:translate(-50%, -50%) scale(1);
-webkit-transform:translate(-50%, -50%) scale(1);
}2.单选打勾再选打勾取消效果wxml:
wx.js
//这条代码在data里写
check:false
radiocon:function(e){
this.setData({
check: !this.data.check
})
console.log("用户打勾的是 ",this.data.check)
},
//这条代码在data里写
check:false
radiocon:function(e){
this.setData({
check: !this.data.check
})
console.log("用户打勾的是 ",this.data.check)
},这样 就完成了单击打勾再击取消。以上。
/* 单选框样式 */
/* 初始样式 */
radio .wx-radio-input{
width: 32rpx;
height: 32rpx;
border-radius: 0
}
/* 选中后的 背景样式 ( 背景 边框 ) */
radio .wx-radio-input.wx-radio-input-checked{
width: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
background:white!important;
}
/* 选中后的 对勾样式
*/
radio .wx-radio-input.wx-radio-input-checked::before{
width: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
line-height: 32rpx;
text-align: center;
font-size:36rpx; /* 对勾大小 */
color:black; /* 对勾颜色
*/
background: white;
transform:translate(-50%, -50%) scale(1);
-webkit-transform:translate(-50%, -50%) scale(1);
}
/* 单选框样式 */
/* 初始样式 */
radio .wx-radio-input{
width: 32rpx;
height: 32rpx;
border-radius: 0
}
/* 选中后的 背景样式 ( 背景 边框 ) */
radio .wx-radio-input.wx-radio-input-checked{
width: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
background:white!important;
}
/* 选中后的 对勾样式
*/
radio .wx-radio-input.wx-radio-input-checked::before{
width: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
line-height: 32rpx;
text-align: center;
font-size:36rpx; /* 对勾大小 */
color:black; /* 对勾颜色
*/
background: white;
transform:translate(-50%, -50%) scale(1);
-webkit-transform:translate(-50%, -50%) scale(1);
}2.单选打勾再选打勾取消效果wxml:
//这条代码在data里写
check:false
radiocon:function(e){
this.setData({
check: !this.data.check
})
console.log("用户打勾的是 ",this.data.check)
},
//这条代码在data里写
check:false
radiocon:function(e){
this.setData({
check: !this.data.check
})
console.log("用户打勾的是 ",this.data.check)
},这样 就完成了单击打勾再击取消。以上。
相关文章:
- js微信小程序实现canvas分享朋友圈海报js大全
- js代码JavaScript中的全局属性与方法深入解析
- js微信小程序swiper组件实现抖音翻页切换视频功能的实例代码js大全
- jskeep-Alive搭配vue-router实现缓存页面效果的示例代码js大全
- js微信小程序清空输入框信息与实现屏幕往上滚动的示例代码js大全
- jsVue循环遍历选项赋值到对应控件的实现方法js大全
- JavaScript详细分析Node.js 多进程
- JavaScript如何配置vue.config.js 处理static文件夹下的静态文件
- jsvue单文件组件无法获取$refs的问题js大全
- js小程序实现多个选项卡切换js大全