E
E
exhang2019-07-29 11:22:49
JavaScript
exhang, 2019-07-29 11:22:49

How to get data from the vue js component in the main application?

I have a component, javascript variable, suggestion:

Vue.component('addressmd', {
 mounted: function () {
suggestion = '123';
}
}

I can’t understand how I can transfer this suggestion to the main application, so that I can work with it in the future?
new Vue({
        el: '#app',
        data: {
            suggestion:null,
}
});

Tell a newbie?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2019-07-29
@Azperin

Duck can it be easier to transfer to the component through props, and not from it? https://ru.vuejs.org/v2/guide/components-props.html

A
Andrey Ololoshchenko, 2019-08-02
@veremii

See the v-model.sync modifier for an example. Or maybe so. inside props component: {suggestion : {default: ()=> {}}}. And when updating the suggestion in the component this.$emit(suggestion)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question