I have some data in my vuex store. I am loading that data in a computed property and based on some condition, I am adding some more data to the computed property's data. then I want to use this to populate a form. The form will have all properties including the newly added property. Now I want the user be able to change values in the form and submit it back to store. However, since everything is happening from Computed property, the user input changes don't reflect. Looking for help...
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Vue Input Computed Example</title>
</head>
<body>
<div id="app" class="container-fluid">
<h2>Vue Input Computed Example</h2>
<!-- I want a form here which is filled with the film data. The idea is that user will update
the data and add data to the newly created properties and then submit form. -->
<input type="text" v-model="item.a"/>
<br /><br />
<input type="text" v-model="item.b"/>
<br /><br />
<input type="text" v-model="item.c"/>
<br /><br />
from computed property 'film': {{film}}
<br /><br />
from data: {{item}}
</div>
<script>
new Vue({
el: '#app',
data: function() {
return {
item: {
a:'',
b:''
}
}
},
computed: {
film () {
var filmdata = {a:'1',b:'2'} // This actually comes from the Vuex store.
// Next based on some condition, I want to add an additional property
// I don't know how to send this to 'item' above. I don't want 'item' to have this additional
// property by default. Add it only if condition satisfies
if (1 == 1) {
filmdata.c = ''
}
return filmdata
}
}
});
</script>
</body>
</html>
name.b
in the feudal – Vamsi Krishna