Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
stchou opened this issue Nov 9, 2016 · 6 comments
Closed

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

stchou opened this issue Nov 9, 2016 · 6 comments

Comments

@stchou
Copy link

stchou commented Nov 9, 2016

@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?

@stchou
Copy link
Author

stchou commented Nov 9, 2016

I resolve it,thanks

@stchou stchou closed this as completed Nov 9, 2016
@yuchonghua
Copy link

How do you solve it? Easy to teach me about it

@mamboer
Copy link

mamboer commented Dec 29, 2016

how?

@bmarkovic
Copy link

bmarkovic commented 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

@zhump
Copy link

zhump commented Apr 22, 2017

@stchou 确实不厚道。。
webpack.base.config.js 中 配置css-loader

  {
            test: /\.css$/, 
            loader: ["vue-style-loader", "css-loader"]
   },

@FlyPointRed
Copy link

app.js 中 加入
image
element ui就在项目中运行正常了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants