# ReferenceError: location is not defined
[Vue warn]: Error in render: "ReferenceError: location is not defined"
ssr レンダリングする際に出る location is not defined エラーは javascript ブラウザー側しか稼働しない location を ssr レンダリングされた際に出るエラー
MDN の location についての解釈
Location インターフェイスは、関連付けられたオブジェクトの場所 (URL) を表します。
Location に対して変更が行われると、関連するオブジェクトに反映されます。
Document インターフェイスおよび Window インターフェイスにはこのような関連付けられた Location があり、それぞれ Document.location および Window.location でアクセスできます。
# 因みに location プロパティ
- href
- protocol
- host
- hostname
- port
- pathname
- search
- hash
- username
- password
- origin
# メソッド
- assign
- reload
- replace
- toString
# エラー対応
- ブラウザー側にレンダリングさせる
if (process.browser) {
var href = location.href
}
- mounted 後に実行させる
mounted() {
var href = location.href
}
- no-ssr client-only 指定