My model is not updating when I enter in any values and when I dispatch to my store, it tells me the object "item" is undefined. Can someone help me out here? I feel like the syntax is correct. This is the actual SFC i am using
<template>
<el-form :model="item" ref="item" label-width="120px">
<el-form-item label="Name" required>
<el-input v-model="item.name" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="Description">
<el-input v-model="item.description"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click='submitForm'>Submit</el-button>
<el-button @click='clearForm'>Clear</el-button>
</el-form-item>
</el-form>
</template>
<script>
export default {
name: 'itemForm',
data () {
return {
item: {
name: '',
description:''
}
}
},
methods: {
submitForm() {
this.$store.dispatch('addItem', this.item)
},
clearForm() {
console.log("CLEAR")
this.$refs['item'].resetFields()
}
},
watch: {
item: function() {
console.log(this.item)
}
}
}
</script>
I have made a usable Jsfiddle: https://jsfiddle.net/zheactj9/1/
$storethat is undefined. Did you register your store (Vuex) properly? Can you please provide the code for it?