We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

VueX binding of $store in templated components



so on the root vue component, I have the typical vuex registration with a store

new Vue({
  router,
  store,
  components: { Home },
  render: h => h(App)
}).$mount('#app');


then in various syncfusion controls I have template functions like...

    <e-tabitem :header='tabPrograms' :content="programs"></e-tabitem>


with either

programs() {
        return { template: { extends: Programs }}
      }

or

programs() {
        return { template: Programs }
      }


so in the component that has these bindings, it has this.$store

however, when the Programs template is created, the this.$store is gone,  so something in the syncfusion controls don't seem to be properly binding with Vuex.  Not sure if I've missed something in the docs, but how do I set it up so it will bind $store  , and for that matter, $router.  (not that I'm using it yet , but it is also missing )



1 Reply

VD Vinitha Devi Murugan Syncfusion Team October 4, 2019 12:08 PM UTC

Hi Keith, 
 
Syncfusion Greetings. 
 
In our analysis, you are expecting “To access the Vue stroe in the content template of Tab”. We were able to achieve this requirement in Tab component by storing the content for the template in Vue state and accessing it from this.$store. Please check the below code block and same can be available in below link. 
 
 
 
      Template1: function() { 
        return { 
          template: Vue.component("Content1", { 
            template: " <div><p>{{content}}</p><div>", 
            store: store, 
            data() { 
              return { content: "" }; 
            }, 
 
            beforeMount: function(e) { 
              this.content = this.$store.state.content2; 
            } 
          }) 
        }; 
 
 
export default new Vuex.Store({ 
  state: { 
    content1: "Place your content here for content 1", 
    content2: "Place your content here for content 2", 
    content3: "Place your content here for content 3", 
  } 
}); 
 
 
Kindly try the above solution and let us know, if you need further assistance on this. 
 
Regards, 
M.Vinitha devi 


Loader.
Up arrow icon