Answer the question
In order to leave comments, you need to log in
How to assign value from mapGetters to data?
There is a textarea
<textarea class="input-container__input" rows="3" placeholder="Введите описание задачи" v-model="formData.description"></textarea>
data() {
return {
formData: {
description: "данные загружаются"
}
}
computed: {
...mapGetters({
getOneTask: 'getOneTask',
}),
},
created() {
// вызываю через mapActions по AJAX загрузить данные
this.loadTaskById(this.$route.params.id);
<b> // ВОТ ЗДЕСЬ С....А НЕ РАБОТАЕТ!!! УЖЕ 2 ДЕНЬ БЬЮСЬ!!!!
this.formData.description = this.getOneTask.description;</b>
},
Answer the question
In order to leave comments, you need to log in
I think for it to work you need getOneTask to return a Promise
Something like this
in actions
async loadTaskById() {
const {data} = await axios.get('[url]');
commit('MUTATE_FORM_DATA', data);
}
async created() {
// вызываю через mapActions по AJAX загрузить данные
await this.loadTaskById(this.$route.params.id);
this.formData.description = this.getOneTask.description
}
this.formData.description = this.getOneTask.description;
Found a solution!!!
This is how I see how the variable has changed and then I can do what I want!
created() {
this.$store.watch(
(state, getters) => getters.getOneTask,
(newValue) => {
console.log("%c ************** " , "background-color:red;color:#fff;");
console.log(newValue);
});
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question