Skip to content

Instantly share code, notes, and snippets.

@alexfinnarn
Created December 3, 2018 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexfinnarn/d96f3b569eafaade010d53b3f7c4135b to your computer and use it in GitHub Desktop.
Save alexfinnarn/d96f3b569eafaade010d53b3f7c4135b to your computer and use it in GitHub Desktop.
template of autocomplete component
<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