react-weui
react-weui copied to clipboard
Citypicker选中和展示不一致
Do you want to request a feature or report a bug (建议还是bug) ?
- bug
What is the current behavior? (现有状况)
- 选中项和emit的text不一致
What is the expected behavior? (应有状况)
- 选中项和emit的text一致
Which versions of React-weui, weui, and which OS and device are affected by this issue? (React-weui版本 weui版本 机型和系统)
- react-weui: 1.0.3
- device: chrome dev tools
- dependencies: redux, react-redux (重要)
重现
- 弹出城市选择器
- 选中:河北 -> 唐山 -> ...
- 选中:天津 -> ... -> ...
- 确定按钮
[数据不一致。]
代码对应位置
updateGroup(item, i, groupIndex, selected, picker) {
const { data, dataMap } = this.props;
//validate if item exists
const { groups, newselected } = this.parseData(data, dataMap.items, selected);
let text = '';
try {
groups.forEach((group, _i) => {
text += `${group['items'][selected[_i]][this.props.dataMap.id]} `;
});
} catch (err) {
//wait
text = this.state.text;
}
//console.log(groups)
this.setState({
groups,
text,
selected: newselected
});
//update picker
picker.setState({
selected: newselected
});
}
建议 将value的赋值放在setState的回调里面