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

59 lines
1.3 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';
import { fetch } from './tbFetchSuggest';
2018-02-12 10:10:51 +00:00
export default {
data () {
return {
data: [],
value: ['b11'],
2019-01-12 03:33:27 +00:00
};
2018-02-12 10:10:51 +00:00
},
methods: {
onChange (value) {
2019-01-12 03:33:27 +00:00
console.log('onChange ', value);
this.value = value;
2018-02-12 10:10:51 +00:00
},
onSelect (value) {
2019-01-12 03:33:27 +00:00
console.log('select ', value);
2018-02-12 10:10:51 +00:00
},
fetchData (value) {
fetch(value, (data) => {
2019-01-12 03:33:27 +00:00
this.data = data;
});
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++) {
// 11 => readonly selected item
2019-01-12 03:33:27 +00:00
children.push(<Option disabled={i === 11} key={i.toString(36) + i}>中文{i}</Option>);
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 readonly default selected item</h2>
<div>
<Select
multiple
value={this.value}
animation='slide-up'
choiceTransitionName='rc-select-selection__choice-zoom'
dropdownMenuStyle={dropdownMenuStyle}
style={{ width: '500px' }}
optionFilterProp='children'
optionLabelProp='children'
placeholder='please select'
onChange={this.onChange}
>
{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>