nuxtServerInit 不起作用 - 上下文:货币转换

我们在使用 nuxtServerInit 时遇到了问题。我们为电子商务网站使用货币切换器。当页面加载时,显示正确的货币(放置在 cookie 中)和转换价格(首先显示基础货币)会有一点延迟。 为此,我们在 store/index.js 中使用了 NuxtServerInit 但它根本不起作用。这是我们的代码:

export const actions = {
  async getForestDetail({$axios,commit}) {

    try {
      const res = await this.$axios.$get("/forests/145764");
      commit("SET_FOREST_DetaILS",res);
    } catch (e) {
      commit("SET_FOREST_DetaILS",{tree_count: 0,co2_compensated: 0});
    }
  },async nuxtServerInit({dispatch,commit}) {
    await dispatch('getForestDetail');
    if (this.$cookies.get('currency_default')) {
      commit('product/SET_CURRENCY',this.$cookies.get('currency_default'))
    }
  }
};

你能帮我解决这个问题吗?也许我错过了什么?

非常感谢,新年快乐! 凯文

syzr12345 回答:nuxtServerInit 不起作用 - 上下文:货币转换

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/1163899.html

大家都在问