|
@@ -1,11 +1,40 @@
|
|
|
<template lang="pug">
|
|
|
.products-searcher
|
|
|
- input(type="text" placeholder="Buscar un producto")
|
|
|
+ input(type="search" placeholder="Buscar un producto" v-model="search")
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import { mapGetters } from 'vuex'
|
|
|
+ import Fuse from 'fuse.js'
|
|
|
+
|
|
|
export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ search: '',
|
|
|
+ fuse: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: mapGetters({
|
|
|
+ products: 'getProducts'
|
|
|
+ }),
|
|
|
+ watch: {
|
|
|
+ search() {
|
|
|
+ console.log(this.products)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.fuse = new Fuse(this.products, {
|
|
|
+ shouldSort: true,
|
|
|
+ threshold: 0.6,
|
|
|
+ location: 0,
|
|
|
+ distance: 100,
|
|
|
+ maxPatternLength: 32,
|
|
|
+ minMatchCharLength: 1,
|
|
|
+ keys: ['name', 'display_name']
|
|
|
+ })
|
|
|
|
|
|
+ console.log(this.fuse)
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|