VueJS access child component’s data from parent

VueJS access child component’s data from parent

Asked on January 10, 2019 in vue.js.
Add Comment


  • 1 Answer(s)

    This module is user friendly,

           VueJS gives answer that’s why it’s known as Vuex. Check whether it is not able to go with Vuex, By creating its own simple store.

           The following this code,

    export default {
        data: {
           items: []
    },
        // Methods that you need, for e.g fetching data from server etc.
     
     fetchData() {
         // fetch logic
    }
    }
    

    From data everywhere, with importing this Store file

     indexview.vue

         import MarkdownStore from '../stores/MarkdownStore'
    export default {
         data() {
            sharedItems: MarkdownStore.data
    },
        created() {
            MarkdownStore.fetchData()
    }
    }
    
    Answered on January 10, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.