V
V
Vanya Huk2017-07-03 14:16:04
JavaScript
Vanya Huk, 2017-07-03 14:16:04

How to call another component method from mounted?

how to call products() method from mounted?

Vue.component('hello-world', {
    template: '#hello-world-template',

    data : function () {
        return{message : 'привет',
            products    : [0,1,2,2,3]}
    },

    mounted : function () {
        this.products()
    },

    methods : {

        products : function () {
            alert()
        }
    }
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-07-03
@vanyahuk

You are doing everything right, only your variable and the products function have the same name, there will be a collision.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question