ant-design-vue/components/vc-select/demo/multiple.vue

75 lines
1.7 KiB
Vue
Raw Normal View History

2018-02-12 10:10:51 +00:00
<script>
2019-01-12 03:33:27 +00:00
import Select, { Option } from '../index';
import '../assets/index.less';
2018-02-12 10:10:51 +00:00
export default {
data () {
return {
useAnim: 0,
value: ['a10'],
2019-01-12 03:33:27 +00:00
};
2018-02-12 10:10:51 +00:00
},
methods: {
onChange (value, options) {
2019-01-12 03:33:27 +00:00
console.log('onChange', value, options);
this.value = value;
2018-02-12 10:10:51 +00:00
},
onSelect (...args) {
2019-01-12 03:33:27 +00:00
console.log('select ', args);
2018-02-12 10:10:51 +00:00
},
onDeselect (...args) {
2019-01-12 03:33:27 +00:00
console.log('deselect ', args);
2018-02-12 10:10:51 +00:00
},
useAnimation (e) {
2019-01-12 03:33:27 +00:00
this.useAnim = e.target.checked;
2018-02-12 10:10:51 +00:00
},
},
render () {
2019-01-12 03:33:27 +00:00
const children = [];
2018-02-12 10:10:51 +00:00
for (let i = 10; i < 36; i++) {
children.push(
<Option key={i.toString(36) + i} disabled={i === 10} title={`中文${i}`}>
中文{i}
</Option>
2019-01-12 03:33:27 +00:00
);
2018-02-12 10:10:51 +00:00
}
const dropdownMenuStyle = {
maxHeight: '200px',
2019-01-12 03:33:27 +00:00
};
2018-02-12 10:10:51 +00:00
return (<div>
<h2>multiple selectscroll the menu</h2>
<p>
<label>
anim
<input checked={this.useAnim} type='checkbox' onChange={this.useAnimation} />
</label>
</p>
<div style={{ width: '300px' }}>
<Select
value={this.value}
animation={this.useAnim ? 'slide-up' : null}
choiceTransitionName='rc-select-selection__choice-zoom'
dropdownMenuStyle={dropdownMenuStyle}
style={{ width: '500px' }}
multiple
allowClear
optionFilterProp='children'
optionLabelProp='children'
onSelect={this.onSelect}
onDeselect={this.onDeselect}
placeholder='please select'
onChange={this.onChange}
onFocus={() => console.log('focus')}
tokenSeparators={[' ', ',']}
>
{children}
</Select>
</div>
2019-01-12 03:33:27 +00:00
</div>);
2018-02-12 10:10:51 +00:00
},
2019-01-12 03:33:27 +00:00
};
2018-02-12 10:10:51 +00:00
</script>