As the topic suggests, I have a particular item in my vuex store which I am bringing into my component in the computed properties section using mapState. This is the code for it:
computed: mapState({
orderTitle: state => state.order.bookTitle,
}),
When I inspect this in the Vuex section of Vue Dev Tools, I can see that it is accurately getting the data from the store.
Now the problem.
I have an input text field which I have put a v-model
on, and associated it with a data
property. What I want to do is pre-populate that text field with the text found in orderTitle
which I am getting from my store
.
I tried doing this by simply assigning the value in the computed property to the data property in the mounted
hook. However, this didn't work.
When I tried to troubleshoot it by doing console.log(this.orderTitle)
to see the value of the computed property in the mounted hook, it showed up as blank.
How come the value is properly appearing in the Vue Dev Tools (and even in the console when I do $vm0.orderTitle
) but not in the mounted hook?
Any thoughts?
Thanks!
mounted
event, because at that point in time it is not yet available. – Bert