mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
docs(fuse): fix fuse.js example (#1229)
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
<template>
|
||||
<v-select :filter="fuseSearch" :options="books" :getOptionLabel="option => option.title">
|
||||
<template #option="{author, title}">
|
||||
{{ title }} <br>
|
||||
<template #option="{ author, title }">
|
||||
{{ title }}
|
||||
<br />
|
||||
<cite>{{ author.firstName }} {{ author.lastName }}</cite>
|
||||
</template>
|
||||
</v-select>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Fuse from 'fuse.js';
|
||||
import books from '../data/books';
|
||||
import Fuse from "fuse.js";
|
||||
import books from "../data/books";
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
books: () => books,
|
||||
books: () => books
|
||||
},
|
||||
methods: {
|
||||
fuseSearch (options, search) {
|
||||
fuseSearch(options, search) {
|
||||
const fuse = new Fuse(options, {
|
||||
keys: ['title', 'author.firstName', 'author.lastName'],
|
||||
shouldSort: true,
|
||||
keys: ["title", "author.firstName", "author.lastName"],
|
||||
shouldSort: true
|
||||
});
|
||||
return search.length ? fuse.search(search) : fuse.list;
|
||||
},
|
||||
},
|
||||
return search.length
|
||||
? fuse.search(search).map(({ item }) => item)
|
||||
: fuse.list;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user