<template> <div id="search-projects"> <input v-model="text" type="search" placeholder="Rechercher..." > </div> </template> <script> import _ from 'lodash'; import { mapMutations } from 'vuex'; export default { name: 'SearchProjects', props: { searchFunction: { type: Function, default: () => { return {} } } }, data() { return { text: null } }, watch: { text: _.debounce(function(newValue) { this.$emit('loading', true); this.SET_CURRENT_PAGE(1); this.searchFunction(newValue) .then(() => { this.$emit('loading', false); }); }, 100) }, methods: { ...mapMutations('projects', [ 'SET_CURRENT_PAGE' ]) } } </script> <style lang="less" scoped> #search-projects { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; input { width: 100%; height: 72%; text-align: left; color: #35495e; padding: 8px 40px 0 8px; border-radius: 5px; border: 1px solid #e8e8e8; font-size: 14px; } } </style>