Итак, у меня есть следующий код в одном из моих компонентов:
export default {
name: 'section-details',
components: {
Loading
},
mounted() {
if (!this.lists.length || !this.section_types.length) {
this.$store.dispatch('section/fetch_section_form_data', () => {
if (this.section) {
this.populate_form();
}
});
}
else if (this.section) {
this.populate_form();
}
},
computed: {
section_types() {
return this.$store.state.section.section_types;
},
lists() {
return this.$store.state.list.lists;
},
loading() {
console.log(this.$store.state.section.loading);
this.$store.state.section.loading;
}
},
.
.
.
}
Как вы можете видеть, у меня есть вычисляемое свойство для "загрузки", которое извлекает атрибут из моего хранилища vuex для выполнения ajaxзапрос.
в моем разделе модуля Vuex у меня есть это:
fetch_section_form_data({ commit }, callback) {
commit("isLoading", true);
sectionService
.fetch_form_data()
.then((data) => {
commit("isLoading", false);
commit("fetch_section_types_success", data.section_types);
commit("list/fetch_lists_success", data.lists, { root: true});
if (callback) {
callback();
}
})
.catch((err) => {
commit("isLoading", false);
})
;
}
тогда в моих мутациях для модуля у меня есть следующий код:
mutations: {
isLoading(state, status) {
state.loading = status;
},
}
Наконец вмой компонент, где я храню свойство загрузки, у меня есть это:
<Loading v-if="loading"></Loading>
В любом случае, по какой-то причине компонент Загрузка не отображается.однако console.log в методе load () возвращает для этого значение true. $ store.state.section.loading.Так что по какой-то причине Vue не воспринимает эту загрузку == true в реальном DOM.Любая помощь будет оценена.