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

localStorage is not a function #4

Open
moedong opened this issue May 16, 2018 · 0 comments
Open

localStorage is not a function #4

moedong opened this issue May 16, 2018 · 0 comments

Comments

@moedong
Copy link
Owner

moedong commented May 16, 2018

nuxt.config.js 设置 ssr 为 true

plugins: [
{ src: '~plugins/flexible.js', ssr: false },
{ src: '~plugins/iview.js', ssr:true }
],

在 layout/default.vue :

将有关 localStorage的操作放在 mounted 中,不能放在 created里面,因为created方法里面,node端渲染和浏览器端都会执行,node环境没有localStorage。

参考:https://segmentfault.com/q/1010000011016483/a-1020000011998745

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

1 participant