S
S
Sergei Gurdjiyan2017-08-04 11:57:52
Vue.js
Sergei Gurdjiyan, 2017-08-04 11:57:52

How to get data from vue component in another component?

There is 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}
    }
];

How can I get the data of the Product_category component in the Edit component?
<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>

Direct appeal is not suitable, because. each route will have its own entity.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2017-08-04
@ilyapashkov02

use store to store data, very convenient!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question