0👍
I’ve used the beforeCreate hook to set the availableQuantity. The adjusted code looks something like this:
<template>
<div>
<div>Initial Quantity {{item.quantity}}</div>
<div>Available Quantity {{availableQuantity}}</div>
</div>
</template>
<script>
export default {
name: "comp1",
props: ["item"]
data: function() {
return {
availableQuantity: 0
}
},
beforeCreate() {
this.availableQuantity = this.item.quantity;
}
}
<script>
- [Vuejs]-How do I assign value to its own key in vuejs
- [Vuejs]-What is this configuration error with Vue.js eslint
Source:stackexchange.com