Search.vue 931 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <div id="search">
  3. <form class="" action="index.html" method="post">
  4. <label for="keywords">
  5. Search
  6. <input
  7. id="keywords"
  8. v-model="keywords"
  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 { mapState, mapActions } from 'vuex'
  26. export default {
  27. name: 'Search',
  28. // data: () => ({
  29. // keywords: ''
  30. // }),
  31. computed: {
  32. ...mapState({
  33. keywords: state => state.Search.keywords
  34. })
  35. },
  36. methods: {
  37. ...mapActions({
  38. getResults: 'Search/getResults'
  39. }),
  40. submit () {
  41. console.log('submited', this.keywords)
  42. this.getResults()
  43. }
  44. }
  45. }
  46. </script>
  47. <style lang="scss" scoped>
  48. </style>