https://developers.weixin.qq.com/miniprogram/dev/component/form.html
form表单中的picker,如果已经进行选择,然后按重置键,picker组键的选项不会重置,仍然是显示原来的选项,而此时按提交,form表单中提交的picker项目的值是“-1”。需要修正。
| 框架类型 | 问题类型 | API/组件名称 | 终端类型 | 微信版本 | 基础库版本 |
|---|---|---|---|---|---|
| 小程序 | Bug | picker和form表单 | 工具 | 只在调试基础库2.8.1 | 2.8.1 |
2 个回答
<button form-type="reset" type="warn" bindtap="pickerrest">重置</button>
<picker bindchange="bindchange" name="piker选择器" mode="selector" range="{{test}}" value="{{index}}">请选择项目:{{test[index]}}</picker>
data: {
flag:0,
test:["篮球","足球","羽毛球"],
index:2
},
pickerrest(){
this.setData({ index: 2 });
},
麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
<form bindsubmit="bindsubmit"><input name="input" type="digit" placeholder="请输入" placeholder-style="color:yellow"></input><slider name="slider" style="width:60%" step="10" show-value="1" value="20" bindchange="sliderbindchanging"></slider><!-- <switch name="盒子" type="checkbox" bindchange="checkbox">盒子</switch > --><switch name="开关" bindchange="switch1" >开关</switch><radio-group name="体育"><radio value="篮1大球">篮1球</radio><radio value="篮2大球">篮2球</radio><radio value="篮3大球">篮3球</radio></radio-group><checkbox-group name="多选"><checkbox value="选A">A</checkbox><checkbox value="选B">B</checkbox><checkbox value="选C">C</checkbox></checkbox-group><textarea name="textarea" placeholder="你好请输入内容" bindblur="radiobindchange" show-confirm-bar auto-height="" style="background:purple"></textarea><button form-type="submit" type="primary">点击提交</button><button form-type="reset" type="warn" bindtap="pickerrest">重置</button><picker bindchange="bindchange" name="piker选择器" mode="selector" range="{{test}}" value="{{index}}">请选择项目:{{test[index]}}</picker></form>data: {flag:0,flag1: 0,test:["篮球","足球","羽毛球"],index:2,img: ["../../images/IMG_3265.JPG", "../../images/IMG_3118.JPG","../../images/IMG_2910.JPG"],imgA: "imgA"},