Skip to content

Instantly share code, notes, and snippets.

@daanfl
Created May 27, 2019 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daanfl/acfb06e6454b60b351a6cfdbd186d323 to your computer and use it in GitHub Desktop.
Save daanfl/acfb06e6454b60b351a6cfdbd186d323 to your computer and use it in GitHub Desktop.
<template>
<div class="row">
<div class="col">
<input type="text" v-model="product">
</div>
<div class="col">
<input type="checkbox" v-model="inStock" id="stock">
<label for="stock">In stock</label>
</div>
<div class="col">
<button @click="saveProduct()">Save</button>
</div>
</div>
</template>
<script>
export default {
data() {
return {
product: '',
inStock: false,
}
},
methods: {
saveProduct() {
if (this.product.length) {
this.$store.dispatch('products/addProduct', {
'name': this.product,
'inStock': this.inStock
});
this.product = '';
this.inStock = false;
}
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment