question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use Element UI ----> ReferenceError: window is not defined

See original GitHub issue

@yyx990803

project base on hacknews

Use the eleme UI (element ui), add code on app.js

import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
import App from './App.vue'

Vue.use(ElementUI)

new Vue({
  el: '#app',
  render: h => h(App)
})

but something wrong with it

ReferenceError: window is not defined

It’s the server side rending cause it?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

28reactions
stchoucommented, Nov 9, 2016

I resolve it,thanks

18reactions
bmarkoviccommented, Apr 10, 2017

@stchou It would be nice if you would tell what was wrong and how you solve it so that others facing the same issue could use your findings at least as a hint. Closing the issue without explaining how you solved the error is horrible ettiquette and against the spirit of open source. Community gave you Vue, give back!

To everyone else that might came across this. The most common source of this error is trying to access the browser window object from a lifecycle hook that actually gets called in SSR. The window object exists only in the browser, and should be used from hooks such as mounted but not, say, created

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window is not defined in Next.js React app - Stack Overflow
So we have to use back window object from the browser. if (typeof window !== "undefined") { // Client-side-only ...
Read more >
How to solve Next.js window is not defined
ReferenceError : window is not defined is a pretty common error you may run into when using Next.js for the first time but...
Read more >
How to solve "window is not defined" errors in React and Next.js
A different solution is to load your Scroll component using dynamic imports and the srr: false option.
Read more >
then is not defined in Element Ui Plus-Vue.js - appsloveworld
Coding example for the question Uncaught ReferenceError: then is not defined in Element Ui Plus-Vue.js.
Read more >
window is not defined on run build with node adapter : r/sveltejs
I wouldn't say this is a hack, this is what the browser boolean is for. window doesn't exist in a node environment so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found