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

打包出错 #45

Closed
osdebianly opened this issue Mar 8, 2017 · 6 comments
Closed

打包出错 #45

osdebianly opened this issue Mar 8, 2017 · 6 comments

Comments

@osdebianly
Copy link

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
Copy link
Member

Justineo commented Mar 8, 2017

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

无法设置主题是指?

@osdebianly
Copy link
Author

<echart class="echarts" :options="option" theme="macarons" ></echart>

设置了主题 但是 没有效果

@Justineo
Copy link
Member

Justineo commented Mar 8, 2017

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

@osdebianly
Copy link
Author

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
Copy link
Member

Justineo commented Mar 8, 2017

import Vue from 'vue'
import ECharts from 'vue-echarts/components/ECharts.vue'
import 'echarts/theme/dark'

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

这样呢?

@osdebianly
Copy link
Author

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

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

2 participants