Search.vue 960 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <div id="search" class="col-11">
  3. <form class="" action="index.html" method="post">
  4. <label htmlFor="keys">Search</label>
  5. <input
  6. id="keys"
  7. v-model="keys"
  8. type="text"
  9. placeholder="search"
  10. >
  11. <input
  12. id="search"
  13. type="submit"
  14. name="search"
  15. value="Search"
  16. @click.prevent="submit"
  17. @keyup.enter="submit"
  18. >
  19. </form>
  20. </div>
  21. </template>
  22. <script>
  23. import { mapActions } from 'vuex'
  24. export default {
  25. name: 'Search',
  26. // data: () => ({
  27. // typed: ''
  28. // }),
  29. computed: {
  30. keys: {
  31. get () { return this.$store.state.Search.keys },
  32. set (value) { this.$store.commit('Search/setKeys', value) }
  33. }
  34. },
  35. methods: {
  36. ...mapActions({
  37. getResults: 'Search/getResults'
  38. }),
  39. submit () {
  40. console.log('submited', this.keys)
  41. this.getResults()
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. </style>