[Vuejs]-Vue2.0 unaccessible variable

0👍

Two options that i can think of :

  1. Passing Props to Route Components

Source : link

In your router :

import main from './main.vue'

    const router = new VueRouter({
      routes: [
        { path: '/main/:id', component: main }
      ]
    })

In your Main.vue

Access to the variable : this.$route.params.id


  1. Save the data in state manager and get access to him through the state in another component Vuex

0👍

Every component instance has its own isolated scope. As stated here: https://v2.vuejs.org/v2/guide/components.html#Passing-Data-with-Props

you cannot (and should not) directly reference parent data in a child component’s template. Data can be passed down to child components using props.

Leave a comment