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

65 lines
1.4 KiB
Vue
Raw Normal View History

2018-02-07 10:56:58 +00:00
<script>
import Select, { Option } from '../index'
import '../assets/index.less'
export default {
data () {
return {
disabled: false,
value: '',
}
},
methods: {
2018-02-12 03:47:57 +00:00
onChange (value, option) {
console.log('onChange', value, option)
2018-02-07 10:56:58 +00:00
this.value = value
},
onKeyDown (e) {
if (e.keyCode === 13) {
console.log('onEnter', this.value)
}
},
2018-02-12 03:47:57 +00:00
onSelect (v, option) {
console.log('onSelect', v, option)
2018-02-07 10:56:58 +00:00
},
toggleDisabled () {
this.disabled = !this.disabled
},
},
render () {
return (<div>
<h2>combobox</h2>
<p>
<button onClick={this.toggleDisabled}>toggle disabled</button>
</p>
2018-02-07 15:03:47 +00:00
<div style={{ width: '300px' }}>
2018-02-07 10:56:58 +00:00
<Select
disabled={this.disabled}
2018-02-07 15:03:47 +00:00
style={{ width: '500px' }}
2018-02-07 10:56:58 +00:00
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>
</div>)
},
}
</script>