- 实现checkbox-group组件既有单选又有多选问题?
wxml代码: <view class="type_box"> <checkbox-group bindchange="applytypeChange"> <block wx:for="{{applytypeList}}" wx:key='value'> <view class="checkbox"> <checkbox value="{{item.id}}" checked="{{item.checked}}"></checkbox> <text value="{{item.id}}" data-id="{{item.id}}" data-name="{{item.name}}">{{item.name}}</text> </view> </block> </checkbox-group> </view> wxss代码: .type_box{ background: #f7f7f7; width: 250rpx; padding: 0 16rpx; height: hidden; line-height: 60rpx; display: inline-block; vertical-align: middle; position: relative; margin: auto; } .checkbox{ width: 240rpx; display: inline-block; vertical-align: text-top; font-size: 31rpx; position: relative; margin-top: -13rpx; } js代码: Page({ data: { applytypeList:[ {name:'首次申领',id:'1'}, {name:'补发',id:'2'}, {name:'换发',id:'3'}, {name:'失效重新申领 ',id:'4'}, {name:'加注',id:'5'} ], applicationtype:'' }, // 选择 checkChange(e) { applytypeChange(e){ let selected = e.detail.value; let applicationtype = this.data.applicationtype; let applytypeList = this.data.applytypeList; // for循环给每一项减0或者用map方法同样减0;如map方法: selected = selected.map(function (item) { return item - 0; }); console.log("旧的applicationtype = " + applicationtype); console.log('======================='); // 清除申请类型中多余的值 for (let i = 0; i < selected.length; i++) { // 判断前4个值是否被点击 if (!applicationtype.includes(selected[i]) && selected[i] != 5) { for (let j = 0; j < selected.length; j++) { if (selected[j] != selected[i] && selected[j] != 5) { // 选中当前点击 去除之前点击 applytypeList[selected[j] - 1].checked = false; applytypeList[selected[i] - 1].checked = true; // 判断点击值中是否有第5个值 if (selected.includes(5)) { applytypeList[4].checked = true; } else { applytypeList[4].checked = false; } this.setData({ applytypeList, }) selected.splice(selected.indexOf(selected[j]), 1); break; } } } } this.setData({ applicationtype: selected, }) console.log("新的applicationtype = " + this.data.applicationtype); }, })
2023-04-04 - picker实现省市二级联动组件获取值?
xml: <picker mode="multiSelector" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{multiArray}}"> <view class="item"><label class="item_title">出生地:</label> <input type="input" placeholder="请选择出生地址" value="{{multiArray[0][multiIndex[0]]}},{{multiArray[1][multiIndex[1]]}}" class="input_text" /> </view></picker> 想让 value="{{multiArray[0][multiIndex[0]]}},{{multiArray[1][multiIndex[1]]}}"用一个变量来显示place, js: var app = getApp() var that var list = [] Page({ data: { place:"", multiIndex:[0,0], multiArray: [ ['北京市', '安徽省', "福建省", "甘肃省", "广东省", "广西省", "贵州省", "海南省", "河北省", "河南省", "黑龙江省", "湖北省", "湖南省", "吉林省", "江苏省", "江西省", "辽宁省", "内蒙古自治区", "宁夏回族自治区", "青海省", "山东省", "山西省", "陕西省", "上海市", "四川省", "天津省", "西藏自治区", "新疆维吾尔自治区", "云南省", "浙江省", "重庆市", "香港", "澳门", "台湾"], ["北京市"]], objectMultiArray:[{ "regid": "2", "parid": "1", "regname": "北京市", "regtype": "1", "ageid": "0" }, { "regid": "3", "parid": "1", "regname": "安徽省", "regtype": "1", "ageid": "0" }, ....]}, onLoad: function(){ that = this }, bindMultiPickerChange: function(e){ console.log("ee====",e) //let place = multiIndex that.setData({ "multiIndex[0]": e.detail.value[0], "multiIndex[1]": e.detail.value[1], }) }, bindMultiPickerColumnChange: function (e){ console.log("laa==",e) switch (e.detail.column){ case 0:list = [] for (var i = 0; i < that.data.objectMultiArray.length;i++){ if (that.data.objectMultiArray[i].parid == that.data.objectMultiArray[e.detail.value].regid){ list.push(that.data.objectMultiArray[i].regname) } } console.log("index==",list[0]) that.setData({ "multiArray[1]": list, "multiIndex[0]": e.detail.value, "multiIndex[1]" : 0 }) console.log("multiArray===",multiArray[1]) } } }) 获取的如place=北京市,北京市, 怎么让place获取,求解
2023-03-16 - 渲染后iconfont图标不显示?
放置图标的位置也在,但是图标不显示? [图片]
2023-03-03 - 仿携程用户信息的小程序添加功能开发?
[图片] 想做一个和携程一样类似的添加信息功能,但不会,求大佬们给解答?(也可推荐一些列子,在此谢谢啦) 携程的样式如下: [图片]
2023-02-27 - input开发下标值提示?
[图片] <view class="item"><label class="item_title">姓名:</label><input type="input" bindinput="inputName" placeholder="请输入姓名" class="input_text" maxlength="16"/></view> 求当把标签放到input框内,显示出下标的一个提示显示?希望推荐相关显示功能的网页?
2023-01-12 - radio怎么拿去id传值?
ml: <view class="identity" style="width:350rpx;"> <label class="identity_title">民族:</label> <view class="wei-input"> <view class="selected" bindtap='mySelect'> <text style="font-size:26rpx;">{{groups_name}}</text> <image src='/pages/images/xiala_1.png'></image> </view> </view> <!-- 下拉需要显示的列表 --> <view class="select_box" wx:if="{{select}}"> <view wx:for="{{groups}}" wx:key="value" > <view class="select_one" bindtap="getNation" data-id="{{item.id}}" data-name="{{item.name}}">{{item.name}}</view> </view> </view> </view> [图片] js: [图片] [图片] [图片] 通过radio单选,先拿到选择的id,可得到的是数组,求大佬们解答,帮我拿到id?(谢谢)
2023-01-10 - const报错?
[图片] 设置验证时,就报错(不是很懂这是什么原因)
2022-11-28 - 小程序在同一个页面中,当改选radio选项的时候,显示出不同的内容,不触碰事件时都隐藏?
[图片] [图片] 使 radio 在不点击是都隐藏,当选择点击后能显示不同的input,并能进行输入 [图片] 同一个页面中,当改选radio选项的时候,怎样实现以上的内容?
2022-11-24