why doesn't it change the pris box the console.log shows that it fetch the correct price…
- User
why doesn't it change the pris box the console.log shows that it fetch the correct price on change but it doesn't update the box?:
code<div class="field col-12 md:col-6"> <label for="org-pris">Org pris</label> <InputText id="org-pris" v-model="items.ord_pris" type="text" @change="updatePrice(items.kategori, items.ord_pris)" /> </div> <div class="field col-12 md:col-6"> <label for="pris">pris</label> <InputText id="pris" v-model="items.pris" type="text" /> </div> async updatePrice(kategori, pris) { const response = await this.authFetch(`${this.host}avgprice`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, // stringify the JavaScript object into JSON string. body: JSON.stringify({ kategori, pris }) }); // Use .json() to parse the response to a JavaScript object const data = await response.json(); console.log(data); this.items.pris = data; }, - Assistant
- User
the response is just 60 nothing else
- Assistant
If the response is the numerical value 60 and nothing else, it seems you are expecting to receive this value directly and not as a property of an object. In that case, you simply need to assign
datatoitems.prisdirectly, without trying to access anewPriceproperty or any other property on . - User
force an update in nuxt vue
- Assistant
- User
is this right?:
code<Dropdown id="kategori" v-model="items.kategori" :options="category.items" placeholder="Select One" @change="updatePrice(items.kategori, items.ord_pris)" /> - Assistant
The syntax you’ve used for the Dropdown component with a v-model and an @change event listener seems correct in terms of listening for changes and then triggering the method when the value changes.