Search.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div id="search" class="col-11">
  3. <form class="search-form">
  4. <label for="keys">Search</label>
  5. <input
  6. id="keys"
  7. v-model="keys"
  8. type="text"
  9. placeholder="search"
  10. @keydown.enter.prevent="submit"
  11. >
  12. <span
  13. v-if="!isloading"
  14. class="mdi mdi-magnify"
  15. title="rechercher"
  16. @click.prevent="submit"
  17. @keydown.enter.prevent="submit"
  18. />
  19. <span
  20. v-else
  21. class="mdi mdi-loading"
  22. title="chargement"
  23. />
  24. <!-- <input
  25. id="submit-search"
  26. type="submit"
  27. name="search"
  28. value="Search"
  29. class="mdi mdi-magnify"
  30. @click.prevent="submit"
  31. @keyup.enter="submit"
  32. > -->
  33. </form>
  34. </div>
  35. </template>
  36. <script>
  37. import { mapActions, mapState } from 'vuex'
  38. export default {
  39. name: 'Search',
  40. // data: () => ({
  41. // typed: ''
  42. // }),
  43. computed: {
  44. keys: {
  45. get () { return this.$store.state.Search.keys },
  46. set (value) { this.$store.commit('Search/setKeys', value) }
  47. },
  48. ...mapState({
  49. isloading: state => state.Search.isloading
  50. })
  51. },
  52. methods: {
  53. ...mapActions({
  54. getResults: 'Search/getResults'
  55. }),
  56. submit () {
  57. console.log('submited', this.keys)
  58. this.getResults()
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. </style>