Created
December 3, 2018 21:51
-
-
Save alexfinnarn/d96f3b569eafaade010d53b3f7c4135b to your computer and use it in GitHub Desktop.
template of autocomplete component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="autocomplete-input"> | |
<input class="form-control" | |
@input="onInput($event.target.value)" | |
@keyup.esc="isOpen = false" | |
@blur="isOpen = false" | |
@keydown.down="moveDown" | |
@keydown.up="moveUp" | |
@keydown.enter="select" | |
v-model="keyword"> | |
<ul class="options-list" v-show="isOpen === true"> | |
<li v-for="(option, index) in fOptions" | |
:key="index" | |
@mouseenter="highlightedPosition = index" | |
@mousedown="select" | |
:class="{'highlighted': index === highlightedPosition}"> | |
{{ option[theKey] }} | |
</li> | |
</ul> | |
</div> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment