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

69 lines
1.5 KiB
Vue
Raw Normal View History

2018-02-07 10:56:58 +00:00
<script>
2019-01-12 03:33:27 +00:00
import Select, { Option } from '../index';
import '../assets/index.less';
2018-02-07 10:56:58 +00:00
export default {
2019-09-28 12:45:07 +00:00
data() {
2018-02-07 10:56:58 +00:00
return {
disabled: false,
value: '',
2019-01-12 03:33:27 +00:00
};
2018-02-07 10:56:58 +00:00
},
methods: {
2019-09-28 12:45:07 +00:00
onChange(value, option) {
2019-01-12 03:33:27 +00:00
console.log('onChange', value, option);
this.value = value;
2018-02-07 10:56:58 +00:00
},
2019-09-28 12:45:07 +00:00
onKeyDown(e) {
2018-02-07 10:56:58 +00:00
if (e.keyCode === 13) {
2019-01-12 03:33:27 +00:00
console.log('onEnter', this.value);
2018-02-07 10:56:58 +00:00
}
},
2019-09-28 12:45:07 +00:00
onSelect(v, option) {
2019-01-12 03:33:27 +00:00
console.log('onSelect', v, option);
2018-02-07 10:56:58 +00:00
},
2019-09-28 12:45:07 +00:00
toggleDisabled() {
2019-01-12 03:33:27 +00:00
this.disabled = !this.disabled;
2018-02-07 10:56:58 +00:00
},
},
2019-09-28 12:45:07 +00:00
render() {
return (
<div>
<h2>combobox</h2>
<p>
<button onClick={this.toggleDisabled}>toggle disabled</button>
</p>
<div style={{ width: '300px' }}>
<Select
disabled={this.disabled}
style={{ width: '500px' }}
onChange={this.onChange}
onSelect={this.onSelect}
onInputKeydown={this.onKeyDown}
notFoundContent=""
allowClear
placeholder="please select"
value={this.value}
combobox
backfill
>
<Option value="jack">
<b style={{ color: 'red' }}>jack</b>
</Option>
<Option value="lucy">lucy</Option>
<Option value="disabled" disabled>
disabled
</Option>
<Option value="yiminghe">yiminghe</Option>
</Select>
</div>
2018-02-07 10:56:58 +00:00
</div>
2019-09-28 12:45:07 +00:00
);
2018-02-07 10:56:58 +00:00
},
2019-01-12 03:33:27 +00:00
};
2018-02-07 10:56:58 +00:00
</script>