Answer the question
In order to leave comments, you need to log in
Vue.js and window is not defined?
I use nuxt
on the page in data like this
data () {
return {
curTrail: window.location.pathname.split('/')[2]
}
},
created() {
this.$store.dispatch('getOneProjects', this.curTrail);
},
Answer the question
In order to leave comments, you need to log in
Nuxt has two-way rendering, when we request a page directly - rendering happens on the server, and node.js does not have a window object
, use context.route
data (context) {
return {
curTrail: context.route.route.path.split('/')[2]
}
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question