Skip to content

Instantly share code, notes, and snippets.

@xphong
Created November 11, 2017 19:16
Show Gist options
  • Save xphong/9fd9c14bdc1a7bc631113835d4cd30fa to your computer and use it in GitHub Desktop.
Save xphong/9fd9c14bdc1a7bc631113835d4cd30fa to your computer and use it in GitHub Desktop.
Marvel API + Vuepack (Vue + Vuex) Blog Post SearchCharacterForm Code
<template>
<div class="search-character__form">
<form @submit.prevent
@submit="handleSearch()">
<div class="ui action input">
<input v-model="name"
placeholder="Character Name"
type="text"
required />
<button class="ui icon pink button">
<i class="search icon"></i>
</button>
</div>
</form>
</div>
</template>
<script>
export default {
data: function () {
return {
name: ''
}
},
methods: {
handleSearch () {
this.$store.dispatch('FETCH_CHARACTERS', this.name)
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment