Search.vue 969 B

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