Nuxt.jsの$route.pathは$nuxt.$route.pathを使え!

Vue.js 2018年9月4日

これマジでトラップだと思うんですが、VueのSPAからNuxtに移行する時に、ルーティング周りで死ぬほどハマったので、メモ。



pathを呼ぶ時は$route.pathじゃなく$nuxt.$route.path

いやマジでこれ誰か教えてくれよ(笑)



nuxt-linkにv-ifで [nuxt] Error while initializing app TypeError: Cannot read property 'toLowerCase' of undefined

これはよくわかんなかったんですが、

<nuxt-link :to="`/path`" v-if="$store.getters.loggedIn">

みたいな$storestategettersを呼んだ時に[nuxt] Error while initializing app TypeError: Cannot read property 'toLowerCase' of undefinedが発生してしまったので、とりあえず一個上のDOMにv-ifを移動して解決。






以上、書き殴りだけど助けになれば。

slont

金融ベンチャーでWebエンジニア

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.