I'm in search of a solution for automatically filling input fields in Vue.js. My form consists of various input types such as text, select dropdowns, and quantities. I want the vCPU, vRAM, and Storage Capacity fields to be filled with predefined values based on the selected Server Flavor from the dropdown.
For example, when selecting 'Flavor 1', the vCPU should display 4, vRAM should show 2, and storage capacity should be 10. However, the quantity field is not updating accordingly.
In the price estimation section, the correct numbers are displayed: vCPU (4), vRAM (2), Storage Capacity (10).
I am uncertain whether I should implement the if conditionals in the <base-quantity>
component during the @updateQuantity
custom event or within the v-if
attribute. Can anyone assist me in resolving this issue?
The full source code can be found on this codesandbox: https://codesandbox.io/s/suspicious-almeida-rjyy9
Lite.vue
<template>
<div class="container">
<h2 class="font-size-26 txt-secondary">Deka Flexi</h2>
<!-- Rest of the Lite.vue template code goes here -->
</div>
</template>
<script>
// Lite.vue script content including data, watch, methods
</script>
BaseQuantity.vue
<template>
<div class="quantity" :class="disabled ? 'quantity__untoggle' : 'quantity__toggle'">
<button type="button" @click="decrement" class="btn quantity__decrement" :disabled="disabled">-</button>
<input type="text" class="quantity__value" :value="quantity" :disabled="disabled" readonly>
<button type="button" @click="increment" class="btn quantity__increment" :disabled="disabled">+</button>
</div>
</template>
<script>
// BaseQuantity.vue script content
</script>