Use Element UI ----> ReferenceError: window is not defined
See original GitHub issueproject 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:
- Created 7 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I resolve it,thanks
@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. Thewindow
object exists only in the browser, and should be used from hooks such asmounted
but not, say,created