Open funkyLover opened 4 years ago
这里还有个新的问题,如果去掉 normalize.css
依然会报错
2020-03-11 17:56:53,392 ERROR 55180 [admin/home.js] server render bundle error, try client render, the server render error ReferenceError: document is not defined
at eval (webpack:///./node_modules/vue-echarts/dist/vue-echarts.js?:1:11870)
at eval (webpack:///./node_modules/vue-echarts/dist/vue-echarts.js?:1:37)
at eval (webpack:///./node_modules/vue-echarts/dist/vue-echarts.js?:1:138)
at Object../node_modules/vue-echarts/dist/vue-echarts.js (__vue_ssr_bundle__:2697:1)
at __webpack_require__ (__vue_ssr_bundle__:20:30)
at eval (webpack:///./app/web/component/common/echart/index.ts?./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/thread-loader/dist/cjs.js??ref--0-1!./node_modules/ts-loader??ref--0-2:6:86)
at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/thread-loader/dist/cjs.js?!./node_modules/ts-loader/index.js?!./app/web/component/common/echart/index.ts?vue&type=script&lang=ts& (__vue_ssr_bundle__:1391:1)
at __webpack_require__ (__vue_ssr_bundle__:20:30)
at eval (webpack:///./app/web/component/common/echart/index.ts?:2:225)
at Module../app/web/component/common/echart/index.ts?vue&type=script&lang=ts& (__vue_ssr_bundle__:227:1)
这里看似是 vue-echarts 导致的
因为 vue-echarts的文档中指出 webpack 环境下默认提供的是源码版本,所以需要配置babel处理
但是来到 easywebpack
中不知道应该如何修改对应配置以做到之前的配置不被破坏的情况下增加新的配置😅
所以我在引入的时候是这样引用的
import ECharts from 'vue-echarts/dist/vue-echarts';
虽然客户端渲染能跑通但是服务端渲染会报错
@funkyLover 从错误看,vue-echarts 不支持 ssr , 具体解决方案 https://www.yuque.com/easy-team/blog/lcbfwb
@hubcarl 感谢,那第一个问题方便帮忙看下吗
import 'normalize.css';
直接在 .vue 页面里面 import 'normalize.css' 试试