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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

VueX binding of $store in templated components

Thread ID:

Created:

Updated:

Platform:

Replies:

147989 Oct 1,2019 03:05 AM UTC Oct 4,2019 12:08 PM UTC Vue 1
loading
Tags: Tab
Keith Nicholas
Asked On October 1, 2019 03:05 AM UTC



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 )



Vinitha Devi Murugan [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon