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.
45 lines
717 B
45 lines
717 B
7 years ago
|
|
||
|
<cn>
|
||
|
#### 基本使用
|
||
|
基本使用。通过 dataSource 设置自动完成的数据源
|
||
|
</cn>
|
||
|
|
||
|
<us>
|
||
|
#### Basic Usage
|
||
|
Basic Usage, set datasource of autocomplete with `dataSource` property.
|
||
|
</us>
|
||
|
|
||
|
```html
|
||
|
<template>
|
||
|
<a-auto-complete
|
||
|
:dataSource="dataSource"
|
||
|
style="width: 200px"
|
||
|
@select="onSelect"
|
||
|
@search="handleSearch"
|
||
|
placeholder="input here"
|
||
|
/>
|
||
|
</template>
|
||
|
<script>
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
dataSource: [],
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
handleSearch(value) {
|
||
|
this.dataSource = !value ? [] : [
|
||
|
value,
|
||
|
value + value,
|
||
|
value + value + value,
|
||
|
]
|
||
|
},
|
||
|
onSelect(value) {
|
||
|
console.log('onSelect', value);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
```
|
||
|
|