mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-03-16 22:10:27 +00:00
autocomplete
This commit is contained in:
parent
2c1b8ecbec
commit
13616b9133
1 changed files with 10 additions and 5 deletions
|
|
@ -22,7 +22,7 @@
|
|||
<md-menu-content>
|
||||
<md-menu-item v-if="items.length"
|
||||
v-for="item in items"
|
||||
@click.native="hit(item)">{{ item.name }}</md-menu-item>
|
||||
@click.native="hit(item)">{{ item[printAttribute] }}</md-menu-item>
|
||||
</md-menu-content>
|
||||
</md-menu>
|
||||
</div>
|
||||
|
|
@ -47,6 +47,10 @@
|
|||
type: String,
|
||||
default: 'q'
|
||||
},
|
||||
printAttribute: {
|
||||
type: String,
|
||||
default: 'name'
|
||||
},
|
||||
minChars: {
|
||||
type: Number,
|
||||
default: 1
|
||||
|
|
@ -122,15 +126,16 @@
|
|||
this.fetchUrl;
|
||||
},
|
||||
hit(item) {
|
||||
// util.warn('You need to implement the `onHit` method', this);
|
||||
this.query = item.name;
|
||||
this.$refs.input.value = item.name;
|
||||
debugger;
|
||||
this.query = item[this.printAttribute];
|
||||
this.$refs.input.value = item[this.printAttribute];
|
||||
this.selected = item;
|
||||
this.onInput();
|
||||
},
|
||||
onInput() {
|
||||
this.updateValues();
|
||||
this.$emit('input', this.selected, this.$refs.input.value);
|
||||
this.$emit('change', this.$refs.input.value);
|
||||
this.$emit('input', this.$refs.input.value);
|
||||
this.$emit('selected', this.selected, this.$refs.input.value);
|
||||
},
|
||||
reset() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue