UNPKG

zent

Version:

一套前端设计语言和基于React的实现

135 lines (129 loc) 2.22 kB
--- order: 14 zh-CN: title: 合并展示选项 zj: 浙江省 hz: 杭州市 nb: 宁波市 xh: 西湖区 yh: 余杭区 wz: 温州市 lw: 龙湾区 xj: 新疆维吾尔自治区 be: 博尔塔拉蒙古自治州 al: 阿拉山口市 en-US: title: Simplify selection zj: Zhejiang hz: Hangzhou nb: Ningbo xh: Xihu yh: YuHang wz: Wenzhou lw: Longwan xj: Xinjiang be: Bortala al: Alashankou --- ```js import { MenuCascader } from 'zent'; class Simple extends React.Component { state = { value: [ ['330000', '330100', '330106'], ['330000', '330100', '330107'], ], options: [ { value: '330000', label: '{i18n.zj}', children: [ { value: '330100', label: '{i18n.hz}', children: [ { value: '330106', label: '{i18n.xh}', }, { value: '330107', label: '{i18n.yh}', }, ], }, { value: '330200', label: '{i18n.wz}', disabled: true, children: [ { value: '330206', label: '{i18n.lw}', }, ], }, { value: '330300', label: '{i18n.nb}', children: [ { value: '330306', label: '{i18n.xh}', }, { value: '330307', label: '{i18n.yh}', }, ], }, ], }, { value: '120000', label: '{i18n.xj}', children: [ { value: '120100', label: '{i18n.be}', }, ], }, ], }; onChange = (value, selectedOptions, meta) => { console.log(meta.simplify(selectedOptions)); this.setState({ value, }); }; render() { return ( <div> <div> <MenuCascader value={this.state.value} options={this.state.options} onChange={this.onChange} expandTrigger="hover" multiple simplifySelection /> </div> <div style={{marginTop: '16px'}}> <MenuCascader value={this.state.value} options={this.state.options} onChange={this.onChange} expandTrigger="hover" multiple simplifySelection simplifySelectionMode="includeDisabled" /> </div> </div> ); } } ReactDOM.render(<Simple />, mountNode); ```