Updating state within a loop using Quasar (VueX)

I am currently working on a Quasar application and utilizing VueX to manage the state of my app.

However, I am encountering an issue when trying to update properties within a for loop. Despite inputting values, they do not seem to be getting set in the state.

Can anyone provide guidance on how to trigger the mutations so that they are called whenever the v-model is changed?

<template>
<div class="row q-col-gutter-x-md">
  <div v-for="(item, index) in items" name="items">

    <h6 class="q-my-sm">Item {{index + 1}}</h6>

    <q-select filled square borderless :v-model="item.prop1" label="Property 1*" :options="options" style="width: 100%;" behavior="menu" class="q-py-md text-subtitle1" />

    <q-input filled square borderless :v-model="item.prop2" label="Property 2*" type="number" min="1" max="9999" style="width: 100%;" />

    <q-input filled square borderless :v-model="item.prop3" label="Property 3*" type="number" min="5" max="90" style="width: 100%;" />
  </div>
</div>
</template>

<script>
export default {
  data() {
    return {
      options: ['A', 'B', 'C', 'D']
    }
  },
  computed: {
    items: {
      get() {
        return this.$store.state.formInputs.items
      },
      set(value) {
        this.$store.commit('formInputs/mutationItems', value)
      }
    }
  },
  methods: {
  }
}
</script>

<style lang="scss">

</style>

Answer №1

After @Yom S. pointed out the issue with the colon in front of (:)v-bind, the code now functions correctly as intended

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Vue js: Automatically assign alternate text to images that are not found

Currently, I am in the process of developing a website that features a variety of products, each with its own unique image. For binding the image URL to the source attribute, I use the following code snippet: <img :src="product.ImageUrl"/> In case ...

The Vue DevTools are functioning as expected, but there seems to be an issue

Encountering a peculiar issue where the value displayed in Vue DevTools is accurate, matching what is expected in my data. When I first click on the "Edit" button for an item, the correct value appears in the browser window as intended. However, upon clic ...

Accessing method from child component in parent component in Vue.js is a common requirement that can be easily

Is there a way to access a method in the parent component from the child component? I attempted to use mixins but found that the function was returning null instead of the expected value. However, when emitting an object, it worked fine in the parent compo ...

Vue js is throwing an error message that says "Reading 'push' property of undefined is not possible"

I've encountered an issue while trying to navigate to other routes. The error I'm receiving is: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'push') at eval (JoinRoom.vue?bd9d:74:1) This is how I pu ...

Coloring a table in vue.js based on performance rankings

I'm facing an issue with sorting my data performance in vue js. Here is the script I have created so far: <template> <div> <div class="row"> <h2> Campaign Performance </h2> <table class=&q ...

Incorporate CSS animations prior to removing an element from an array

Before removing an item from my data table, I want to implement a CSS animation. The deletion is initiated by the @click event. I would like to preview the effect of my animation (class delete_animation) before proceeding with the actual removal. var vm ...

Utilize Vue-svg-inline-loader to send props and transform an image into svg format in Vue applications

Currently, I am utilizing the vue-svg-inline-loader In my initial component, I pass the source of the SVG image as a prop: <IconComponent :imgIcon="'../../assets/img/icon-example.svg'" /> Then, in my second component, I receive this prop ...

Unlock the full potential of Laravel and Vue.js with these advanced techniques

I am currently working with vue.js 2.0 and Laravel 5.4. I am interested in finding a more efficient way to pass data from Controllers to views without losing the value or being overwritten by the v-model. When using Vue.js, the value in data is defined li ...

Oops! It seems like there was a mistake. The ReferenceError is saying that Vue is

I've been working on creating a new app, but I keep running into an issue. Unidentified Reference Error: Vue is not recognized. <template> <v-app> <div id="example-1"> <v-btn v-on:click="counter += 1">Add 1</v-bt ...

Components within Vue functional components

During my exploration of functional components in Vue, I came across an interesting discovery. It seems that the components property cannot be used to declare sub-components for functional components. Attempting to do so leads to an Unknown custom element ...

Issue with <router-view> component after updating to vue.js 2.0

I am currently facing an issue with rendering a component through router-view using vue.js 2.0 and vue-router. Upon inspecting vue devtools, I noticed the "fragment" label next to router-view, but no additional information was provided. It is worth menti ...

Using vue-select: In VueJs, how to pass an option slot from a grandparent component

Utilizing a custom dropdown component called 'vue-select', there is an option to customize the options view using slots as detailed in this documentation -> https://vue-select.org/guide/slots.html I am aiming to achieve a similar customization b ...

Tips for removing the error hint when focusing on input fields in VueJS

Having an issue with an error popping up when I focus on my input. Here's the code snippet: <v-text-field v-model="models.codePostal" label="Code postal" :rules="regles.codePostal" :hint="this.models.communeRe ...

An error occurred: gyp ERR! stack - The command `python -c import sys; print "%s.%s.%s" % sys.version_info[:3]` has failed

While attempting to npm install in a Vue project, I encountered an error even after running vue create (name): npm ERR! gyp verb check python checking for Python executable "c:\Python310\python.exe" in the PATH npm ERR! gyp verb `which` ...

Testing Vue with Jest - Unable to test the window.scrollTo function

Is there a way to improve test coverage for a simple scroll to element function using getBoundingClientRect and window.scrollTo? Currently, the Jest tests only provide 100% branch coverage, with all other areas at 0. Function that needs testing: export de ...

What is the best way to incorporate a vanilla javascript function into a vue.js application?

Consider a vanilla JavaScript function like this: if (window.devicePixelRatio >= 2) { document.querySelectorAll('img.retina').forEach(function (e) { let parts = e.src.split('.'); let ext = parts.pop(); i ...

What is the most effective way to ensure that a child component only executes when a link is clicked on the Vue component?

There are two components in my code The first component, which is the parent component, looks like this : <template> <ul class="list-group"> <li v-for="item in invoices" class="list-group-item"> <div class="ro ...

What steps can I take to ensure that the v-main element occupies at least 70% of the viewport height in Vuetify?

As a newcomer to Vuetify, I am still learning the ropes. One thing I've noticed is that <v-main> automatically expands to fill the space between <v-app-bar> and <v-footer>, taking up the entire viewport height. My concern arises wh ...

Utilize a method in Vue.js to filter an array within a computed property

I have a question regarding my computed property setup. I want to filter the list of courses displayed when a user clicks a button that triggers the courseFilters() method, showing only non-archived courses. Below is my current computed property implement ...

How can you identify when a Vuetify radio button is re-selected?

Currently, I am developing a wizard that involves triggering navigation when a radio button is selected. Users should also be able to go back and change their previous choices. However, one issue I have encountered is the difficulty in detecting a re-selec ...