You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/vc-select/demo/combobox.vue

64 lines
1.3 KiB

7 years ago
<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>
<div style={{ width: 300 }}>
<Select
disabled={this.disabled}
style={{ width: 500 }}
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>