Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
v-autocomplete
Advanced tools
Autocomplete component for Vue.js
yarn add v-autocomplete
npm i --save v-autocomplete
import Vue from 'vue'
import Autocomplete from 'v-autocomplete'
// You need a specific loader for CSS files like https://github.com/webpack/css-loader
import 'v-autocomplete/dist/v-autocomplete.css'
Vue.use(Autocomplete)
<!-- Include after Vue -->
<link rel="stylesheet" href="v-autocomplete/dist/v-autocomplete.css"></link>
<script src="v-autocomplete/dist/v-autocomplete.js"></script>
<script>
Vue.use(Autocomplete)
</script>
<template>
<v-autocomplete :items="items" v-model="item" :get-label="getLabel" :component-item='template' @update-items="updateItems">
</v-autocomplete>
</template>
<script>
import ItemTemplate from './ItemTemplate.vue'
export default {
data () {
return {
item: {id: 9, name: 'Lion', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.'},
items: [],
template: ItemTemplate
}
},
methods: {
getLabel (item) {
return item.name
},
updateItems (text) {
yourGetItemsMethod(text).then( (response) => {
this.items = response
})
}
}
}
</script>
ItemTemplate example:
<template>
<div>
<b>#{{item.id}}</b>
<span>{{ item.name }}</span>
<abbr>{{item.description}}</abbr>
</div>
</template>
<script>
export default {
props: { item: { required: true } }
}
</script>
Name | Type | Required | Default value | Info |
---|---|---|---|---|
items | Array | Yes | List items | |
component-item | Vue Component or Function or String | No | Item | Item list template |
placeholder | String | No | ||
min-len | Number | No | 3 | Min length to trigger the updateItems event |
wait | String | No | 500 | Miliseconds dela to trigger the updateItems event |
get-label | Function | No | function(item) { return item } | Anonymous function to extract label of the item |
value | Mixed | No | Initial value (use v-model) |
Name | Params | Info |
---|---|---|
change | text: Text of search input | Triggered after every change in the search input |
update-items | text: Text of search input | Same as change, but respecting min-len and wait |
Just overwrite their css classes. See the structure in stylus lang:
.v-autocomplete
.v-autocomplete-input-group
.v-autocomplete-input
.v-autocomplete-list
.v-autocomplete-list-item
Follows the css used in the DEMO:
.v-autocomplete
.v-autocomplete-input-group
.v-autocomplete-input
font-size 1.5em
padding 10px 15px
border-radius 5px
box-shadow none
border 2px solid #157977
width calc(100% - 30px)
outline none
&.v-autocomplete-selected
.v-autocomplete-input
color green
background-color #f2fff2
.v-autocomplete-list
width 100%
text-align left
border 1px solid #157977
max-height 400px
overflow-y auto
.v-autocomplete-list-item
cursor pointer
background-color #fff
padding 10px
border-bottom 1px solid #157977
&:last-child
border none
&:hover
background-color #eee
This project is licensed under MIT License
FAQs
Autocomplete component for Vue.js
The npm package v-autocomplete receives a total of 1,800 weekly downloads. As such, v-autocomplete popularity was classified as popular.
We found that v-autocomplete demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.