[Vuejs]-Proper way to dynamically set many inputs values, getting data from Vuex store

0👍

Export a function that will return data
// data.js

export function CurriculumVitae() {
    return {data: {name: 'John Doe', gender: 'Male'} }
}

Import the function in a store file
// store.js

import {CurriculumVitae} from 'data'

Instantiate the function.
//store.js

const store = new Vuex.Store({
state: {
    cvs: CurriculumVitae() // here

In a component file
// myComponent.vue

computed: {
    cvs(){
        return store.state.cvs // here
    }
}

<input type="text" :value="cvs.data.name"> <!-- here -->

See if this works.

Leave a comment