An open API service indexing awesome lists of open source software.

https://github.com/lpreterite/iview-typeahead-input

typeahead component for iview
https://github.com/lpreterite/iview-typeahead-input

input iview typeahead vue

Last synced: 3 months ago
JSON representation

typeahead component for iview

Awesome Lists containing this project

README

        

# iview-typeahead-input
typeahead component for iview by [vue-typeahead](https://github.com/pespantelis/vue-typeahead)

## How to use
### setup
```
npm install lpreterite/iview-typeahead-input
```

### use
```
import Vue from 'vue';
import TypeaheadInput from 'iview-typeahead-input';
import 'iview/dist/styles/iview.css';
import axios from 'axios';

Vue.prototype.$http = axios;
Vue.component('TypeaheadInput', TypeaheadInput);

var vm = new Vue({
el: '#app',
data: function(){
return {
src: '//localhost:8080/typeahead',
input: '',
selection: {
id: 0,
name: ''
}
}
},
methods: {
convent(data){
return data;
}
}
})
```

### template
```




```

### props

`src`: 数据源url

`limit`: 显示item最大数

`minChars`: 响应字符数,输入字符超出时才响应请求

`autocomplete`: 自动补全

`paramName`: 请求时的字段名称,默认`keywords`(?keywords=xxx)

`itemTitleKey`: item显示字段,默认`name`

`selectedFirst`: 自动选择第一个,默认`true`

`convent`: 请求后的数据处理方法,可选

`v-model`: 绑定输入框内容

### methods

`clear()` 清除当前状态

### attr

`isEmpty`: 输入空是否为空

`isDirty`: 用于判断是否已选择

`hasItems`: 用于判断是否有数据返回

#### attr example
```
{
...
methods: {
test(){
console.log(this.refs.typeahead.isDirty);
}
}
...
}
```

## Build
```
npm i
npm run build
```

## Test
```
npm i
npm run mock
npm run dev
```