ecomfe / vue-echarts

Vue.js component for Apache ECharts™.
https://vue-echarts.dev
MIT License
9.64k stars 1.48k forks source link

打包出错 #45

Closed osdebianly closed 7 years ago

osdebianly commented 7 years ago
node -v 
v7.6.0
npm -v
4.1.2
import  VueECharts from 'vue-echarts/components/ECharts.vue'
Vue.component('echart', VueECharts);

使用 webpack 打包出错

ERROR in ./~/buble-loader!./~/vue-loader/lib/selector.js?type=script&index=0!./~/vue-echarts/components/ECharts.vue
Module parse failed: /Users/lyfing/Code/laravel-vue-starter/node_modules/buble-loader/index.js!/Users/lyfing/Code/laravel-vue-starter/node_modules/vue-loader/lib/selector.js?type=script&index=0!/Users/lyfing/Code/laravel-vue-starter/node_modules/vue-echarts/components/ECharts.vue Unexpected token (155:13)
You may need an appropriate loader to handle this file type.
|         return
|       }
|       return var ref = this.chart;
|       ref[name].apply(ref, args)
|     },
 @ ./~/vue-echarts/components/ECharts.vue 8:18-101
 @ ./resources/assets/js/admin.js

已配置

 {
          test: /\.js$/,
          loader: 'babel',
          exclude: /node_modules/
 }

使用 import VueECharts from 'vue-echarts' 编译通过,页面显示正常,但是无法设置主题

Justineo commented 7 years ago

使用 Webpack 1 的话,可以参考 README 这里vue-cli 默认生成的配置把 node_modules 排除了,你引用里面的 ES Next 源文件当然就失败了。

无法设置主题是指?

osdebianly commented 7 years ago
<echart class="echarts" :options="option" theme="macarons" ></echart>

设置了主题 但是 没有效果

Justineo commented 7 years ago

有没有 import 'echarts/theme/macarons' 呢?

osdebianly commented 7 years ago
import VueECharts from 'vue-echarts'
import 'echarts/theme/macarons.js'  
//import  VueECharts from 'vue-echarts/components/ECharts.vue'
Vue.component('echart', VueECharts);

加上后,主题并没有改变

参考 README ,使用import VueECharts from 'vue-echarts/components/ECharts.vue'


                {
                    test: /\.js$/,
                    loader: 'babel',
                    include: [
                        path.join(__dirname, 'src'),
                        path.join(__dirname, 'node_modules/vue-echarts')
                    ],
                    exclude: /node_modules(?![\\/]vue-echarts[\\/])/
                }

还是一样错误

Justineo commented 7 years ago
import Vue from 'vue'
import ECharts from 'vue-echarts/components/ECharts.vue'
import 'echarts/theme/dark'

// registering component
Vue.component('chart', ECharts)

这样呢?

osdebianly commented 7 years ago

还是一样,折腾累了,由于只是画简单线条,用了 vue-charts, 最后感谢您的回复 可以关闭这个issues