1๐
โ
data
in Vuejs is a function that returns an object. Your code is not returning an object.- Your prop name is same the data name. They should be different.
Try the following code:
[...some layout...]
<a @click="addElement" id="addBtn">Add</a>
</span>
</div>
</template>
<script>
export default {
props: [
'routes'
],
data: function () {
return { // Object being returned
storedRoutes: this.routes // props can be directly accessed using `this`
}
},
methods: {
addElement: function () {
this.storedRoutes.push( {[...some object...]} );
}
}
}
</script>
I also changed this.props.routes
to this.routes
๐คAnkit Kante
Source:stackexchange.com