Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

computed property does not read store in Nuxt #1

Open
simongcc opened this issue May 11, 2018 · 0 comments
Open

computed property does not read store in Nuxt #1

simongcc opened this issue May 11, 2018 · 0 comments

Comments

@simongcc
Copy link

simongcc commented May 11, 2018

Hello! I have implemented similar solutions and applied the following to store/index.js
Just share here in case anyone needed

Because by the time if loading the computed property by Nuxt, it is not yet mounted, so any after-mount property for non-ssr environment such as `this.$store.state.route.path is not yet available.

// store/index.js
// tested on [email protected]
import { sync } from 'vuex-router-sync'

export default {
  actions: {
    async nuxtServerInit ({ dispatch }, { app }) {
      console.log('nuxtServerInit in index');
      sync(app.store, app.router); // for life cycle such as computed value which is before mounted
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant