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

64 lines
1.3 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: {
onChange (value) {
this.value = value
},
onKeyDown (e) {
if (e.keyCode === 13) {
console.log('onEnter', this.value)
}
},
onSelect (v) {
console.log('onSelect', v)
},
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>