Vuex状态数据不等于SSR的数据

时间:2019-10-04 08:41:27

标签: express vuejs2 vuex server-side-rendering

我正在将express.js用于SSR。

当我在服务器上请求serverPrefetch时,响应返回成功,并且页面已加载。但是起初,数据不正确,无法显示其他数据或旧数据。

在安装组件时更新了正确的数据,但是服务器端组件与正确的数据不匹配

像这样。 image

那是我的代码

getCompanyProf () {
  registerStoreModule({
    module: companyProfileModule,
    moduleName: 'companyProfile',
    store: this.$store
  })
  let paramsArr = this.$route.params.id.split('-')
  let params = {
    companyProfileParams: {
      profileId: paramsArr[paramsArr.length - 1],
      companyId: paramsArr[paramsArr.length - 2],
      clientType: 'web',
      hash: this.$route.query.hash ? this.$route.query.hash : null,
      isShadow: this.$route.query.isShadow ? 1 : 0
    },
    companyProfileJobsParams: {
      profileId: paramsArr[paramsArr.length - 1],
      companyId: paramsArr[paramsArr.length - 2],
      pageNumber: 1,
      pageSize: 9
    }
  }
  this.$store.dispatch(GET_COMPANY_PROFILE, params.companyProfileParams)
}

serverPrefetch () {
this.getCompanyProf()},

0 个答案:

没有答案