2017-08-04 31 views
0

有一个VUE royter如何从另一个组件中的vue组件中检索数据?

..... 
const Edit = Vue.component('edit', require('./components/pages/edit.vue')); 
const Product_category = Vue.component('home', require('./components/pages/product_categories.vue')); 

const routes = [ 
    ........ 
    { 
     path: '/product_categories', 
     name: 'product_categories', 
     component: Product_category 
    }, 
    { 
     path: '/product_categories/edit/:id', 
     name: 'product_categories_edit', 
     components: {default: Edit, entity: Product_category}, 
     props: {default: true, entity: true} 
    } 
]; 

我怎样才能在组件PRODUCT_CATEGORY componate编辑数据?

<script> 
export default { 
    props: ['id', 'entity'], 
    mounted: function() { 
     console.log('Admin edit page mounted.'); 
     console.log(this.entity); // Eror 
     console.log(entity); // Eror 
     this.getData(); 
    }, 
} 
</script> 

直接上诉并不合适,因为每个路由器都有自己的实体。

回答

相关问题