我需要让远程数据显示在每个页面中。
此调用在以下位置执行store/index.js
:
export const state = () => ({
contact: {
hello: "World"
}
});
export const actions = {
async nuxtServerInit({ commit, state }) {
const { contactData } = await this.$axios.get("/contact");
commit("SET_CONTACT", contactData);
}
};
export const mutations = {
SET_CONTACT(state, contactData) {
state.contact = contactData;
}
};
问题是store中的contact
turns的值undefined
,而预期的内容是通过axios检索的(检索到的内容显示在SSR控制台...)
我在这里想念什么?