DEVHIDE
        • Home (current)
        • About
        • Contact
        • Cookie
        • Home (current)
        • About
        • Contact
        • Cookie
        • Disclaimer
        • Privacy
        • TOS
        Login Or Sign up

        How to change props in child component created using v-for in VueJs 3

        507 Views Asked by Bilal At 15 November 2022 at 02:58 2025-12-12T21:19:41.125000

        I have a parent component creating child components using v-for directive:

        <div class="planlist">
            <ul id="planOl">
            <PlanLego
            v-for="action in store.plan"
                :v-if="action !== activeStep"
                :action_id="action.act_id"
                :actor="action.actor"
                :blocked="action.blocked"
                :key="action.act_id"
                @choose="planClick"
                @fix="changeActor"
            />
            </ul>
        </div>
        

        and I'm emitting a signal from the child component:

        this.$emit('fix', {
             act_id: this.action_id,
             actor: this.actor
        });
        

        My question is:

        how can I access and change the properties (for example actor) of this specific child component that emitted the signal? thanks in advance.

        vue.js vue-component vuejs3 publish-subscribe vue-events
        Original Q&A
        1

        There are 1 best solutions below

        0
        Rohìt Jíndal Rohìt Jíndal On 15 November 2022 at 08:17 BEST ANSWER

        As per my understanding, You want to update the actor for the specific child in the parent component based on the act_id passed from child. If Yes, You can achieve this by iterating the original array object in the parent.

        In the parent component, Your changeActor method should be like this :

        In template :

        @fix="changeActor($event)"
        

        In script :

        changeActor(emittedObj) {
            store.plan.forEach(item => {
                if (item.act_id === emittedObj.act_id) {
                    item.actor = emittedObj.actor
                }
            });
        }
        

        Related Questions in VUE.JS

        • Problems with matter.js and i18n in vue.js
        • Form Validation not working in custom component Vue
        • Authenticating vue app on each route change
        • Vue/TailwindCSS - Content is behind Sidebar
        • Vue3 Suspense Parent > Child Animation
        • Pass dynamic object data via nuxt-link to component
        • Failed to resolve import, but the path is valid, and detected as such by VSCode
        • how to use less variables in vue components?
        • Prevent a webpage from navigating away
        • Creating a modal window in product edit page in Shopware6 and saving data to custom table(repository) from a form within the modal window
        • How do I fix (or ignore) a TypeScript error that's inside a HTML template?
        • Vue.js Checkbox Alignment Issue: Centering Checkboxes Within Table Cells
        • How to reset vue product filter?
        • Vue display output of two dimensional array
        • vue js error when adding bonus items to another item

        Related Questions in VUE-COMPONENT

        • tsParticles onHover not working on my Vue Project
        • How to dynamically switch between two images onclick in Vue.js
        • How can i display elements?
        • How to toggle a v-if
        • Problems in Validations via Web Service in a Vue 3 Application
        • vuetify data-table-server binding paging properties
        • I need to send an id from read component to update component. The id must be obtained by function updateItem(). But id is not sent to the child pag
        • Vuejs child component props does not update when parent component update props value
        • Handling a this.$router.replace(href); in vue 2
        • diferrence between new vue & vue.createapp
        • Is it possible to return a value from the $emit?
        • Passing object with reactive properties as a prop triggers child component onUpdated hook when updating parent component state
        • Dynamic image loading to not work in Vue project!! On no dynamic everything loads correct
        • Error Element Plus Dynamic Tab component in Vue 3
        • vue-hotel-datepicker is not working for PST — Pacific Standard Time

        Related Questions in VUEJS3

        • Problems with matter.js and i18n in vue.js
        • Vue3 Suspense Parent > Child Animation
        • Problem sending HTTP post request from VUE to ASP.NET Core MVC project
        • How to import a local image in vuex store without using axios
        • Vue TransitionGroup not working properly because of css transition
        • tsParticles onHover not working on my Vue Project
        • Vue.js Event Emitted in Child Component Not Detected by Parent Component
        • Resource URI is recognised but page wont load and browser throws 404, route:list says the route exist
        • vue 3 phaser and spine.js - Uncaught TypeError: Cannot read properties of undefined (reading 'data')
        • Inertia/Vue: keep getting props undefined error
        • How to make source dynamic for vue-i18n
        • How do I dynamically handle endless nested routes with Nuxt 3?
        • Vue 3 router changing <routing-view/> but not URL
        • Creating base pinia action that can be mixed-in to several stores with typescript
        • Vue.js - define v-model with defineProps and defineModel

        Related Questions in PUBLISH-SUBSCRIBE

        • How to avoid duplicates with the pull-based subscribe model?
        • What's the right ZMQ architecture for my scenario?
        • App didn't recieved a gcp pubsub message for a minute
        • bun runtime doesnt work with SKD ably javascript starting v2.0.0
        • How would the Broker pattern look like in Rust?
        • akka PubSub not working across distributed system
        • Google PubSub Lite one subscriber with multiple partitions
        • I have a question about the Pub/Sub structure of Redis
        • RabbitMQ. Client cannot publish message to queue
        • Pull PubSub Message through Proxy server - Python
        • Android server notification implementation in app purchase
        • FastDDS Publisher and Subscriber won't match in demo code
        • How to subscribe/consume multiple topics from multiple subscriptions declaratively with Dapr pub/sub component?
        • How to subscribe/consume multiple topics from multiple subscriptions programmatically with Dapr pub/sub component?
        • Enforce Unique Publisher/Producer on a Azure Service Bus Topic

        Related Questions in VUE-EVENTS

        • emit not being triggered within sweetalert once deployed
        • vue 3 key events on table
        • Problems with passing event from child component. Vue 3
        • Vue / Nuxt 3 Collapse component function from parent
        • What is the alternative to using this.$on method for listening to events in the Vue 3 setup script?
        • Listen on emitted events on component instance via this.$ref
        • Vue.js Events: How to detect if key is pressed while the mouse is over a certain element?
        • Vue.js3 event @keydown.esc on text input is not triggered
        • How to change props in child component created using v-for in VueJs 3
        • TypeError: this.$eventBus is not a function at Proxy.mounted
        • Should I use Vuex Store + watch variable as a way to simulate event?
        • how to manage v-on/@ in dynamic components <component :is="currentPage" etc. ></component> structure in vue3 options api
        • Vue 3 event/listener not communicating properly
        • How to fire an $emit event from Vue Composable
        • Vue "emit" alternative

        Trending Questions

        • UIImageView Frame Doesn't Reflect Constraints
        • Is it possible to use adb commands to click on a view by finding its ID?
        • How to create a new web character symbol recognizable by html/javascript?
        • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
        • Heap Gives Page Fault
        • Connect ffmpeg to Visual Studio 2008
        • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
        • How to avoid default initialization of objects in std::vector?
        • second argument of the command line arguments in a format other than char** argv or char* argv[]
        • How to improve efficiency of algorithm which generates next lexicographic permutation?
        • Navigating to the another actvity app getting crash in android
        • How to read the particular message format in android and store in sqlite database?
        • Resetting inventory status after order is cancelled
        • Efficiently compute powers of X in SSE/AVX
        • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

        Popular # Hahtags

        javascript python java c# php android html jquery c++ css ios sql mysql r reactjs

        Popular Questions

        • How do I undo the most recent local commits in Git?
        • How can I remove a specific item from an array in JavaScript?
        • How do I delete a Git branch locally and remotely?
        • Find all files containing a specific text (string) on Linux?
        • How do I revert a Git repository to a previous commit?
        • How do I create an HTML button that acts like a link?
        • How do I check out a remote Git branch?
        • How do I force "git pull" to overwrite local files?
        • How do I list all files of a directory?
        • How to check whether a string contains a substring in JavaScript?
        • How do I redirect to another webpage?
        • How can I iterate over rows in a Pandas DataFrame?
        • How do I convert a String to an int in Java?
        • Does Python have a string 'contains' substring method?
        • How do I check if a string contains a specific word?
        .

        Copyright © 2021 Jogjafile Inc.

        • Disclaimer
        • Privacy
        • TOS
        • Homegardensmart
        • Math
        • Aftereffectstemplates