mrKorg
@mrKorg
web developer

Как получить data из vue компонента в другом компоненте?

Есть vue royter
.....
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}
    }
];

Как я могу получить data компонета Product_category в компонете Edit?
<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>

Прямое обращение не подходит, т.к. у каждого роута будет свой entity.
  • Вопрос задан
  • 759 просмотров
Пригласить эксперта
Ответы на вопрос 1
@kristenstewartdadada
Frontend Developer
используйте store для хранения данных, очень удобно!
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы