apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.3k stars 19.61k forks source link

__DEV__ is not defined #6111

Closed lulu3976003 closed 7 years ago

lulu3976003 commented 7 years ago

One-line summary [问题简述]

vue项目 webpack 引入 echarts 第一次进如没有问题 刷新就会报错500 显示DEV not defined image

Version & Environment [版本及环境]

Expected behaviour [期望结果]

ECharts option [ECharts配置项]

option = {
color: colors,
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross'
                        }
                    },
                    grid: {
                        right: '20%'
                    },
                    toolbox: {
                        feature: {
                            dataView: {show: false, readOnly: true},
                            saveAsImage: {show: true}
                        }
                    },
                    legend: {
                        data:['打印数量','扫码数量','扫码率']
                    },
                    xAxis: [
                        {
                            type: 'category',
                            axisTick: {
                                alignWithLabel: true
                            },
                            data: this.xAxisdata
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value',
                            name: '数量',
                            position: 'right',
                            axisLine: {
                                lineStyle: {
                                    color: colors[0]
                                }
                            },
                            axisLabel: {
                                // formatter: '{value} ml'
                            }
                        },
                        {
                            type: 'value',
                            name: '扫码率',
                            min: 0,
                            max: 100,
                            position: 'left',
                            axisLine: {
                                lineStyle: {
                                    color: colors[2]
                                }
                            },
                            axisLabel: {
                                formatter: '{value} %'
                            }
                        }
                    ],
                    dataZoom: [
                        {
                            type: 'slider',
                            show: true,
                            start: 1,
                            end: 3
                        }
                    ],
                    series: [
                        {
                            name:'打印数量',
                            type:'bar',
                            data:this.printedata,
                        },
                        {
                            name:'扫码数量',
                            type:'bar',
                            data:this.scandata
                        },
                        {
                            name:'扫码率',
                            type:'line',
                            yAxisIndex: 1,
                            data:this.scanratedata
                        }

                    ]
}

Other comments [其他信息]

pissang commented 7 years ago

能发发一下你完整的能复现的项目

lulu3976003 commented 7 years ago

自己定位了一下错误 我这个是vue-cli搭建的项目 现在是只要引用echarts 第一次进没有问题 刷新就会报上面的图的错误 500的错误 不引入没问题

pissang commented 7 years ago

这个是编译时的环境变量,如果你是 webpack 的话可以考虑参考 https://github.com/ecomfe/echarts/blob/master/webpack.config.js#L7 加入

bxychy commented 6 years ago

老铁我跟你是一样的问题,有什么解决的方法啊

bxychy commented 6 years ago

还是不行。是我没改对么。。。我在webpack.base.conf.js里面加了var webpack = require("webpack")

darkurse commented 6 years ago

I have the same issue but I am using angular cli. Should I define this DEV variable somewhere like the environment.ts or environment.prod.ts ?

bxychy commented 6 years ago

我的问题和vue中 import 失败 #6987是一样的,用的也是vue2.但是我按照里面的方法试了一遍还是不行,老铁会说中文么。

hefeng1208 commented 6 years ago

@zsychy 在 webpack的配置里面加一个配置

plugins: [
  new webpack.DefinePlugin({
    __DEV__: false
  })
]
bxychy commented 6 years ago

我加了,但是我不知道加在那一块里面。。可能没加对地方。。 @hefeng1208

hefeng1208 commented 6 years ago

@zsychy webpack.base.conf.js 或者说你的配置文件里面 设置插件的地方

bxychy commented 6 years ago

是module下面的rules块里面么。。。萌新没设置过插件

xiguayizu commented 6 years ago

就是在build\webpack.dev.conf.js 里面的plugins参数

TaylorPzreal commented 6 years ago

angular4也是一样的问题,echarts最新版本

function enableClassExtend(RootClass, mandatoryMethods) {

    RootClass.$constructor = RootClass;
    RootClass.extend = function (proto) {

        if (__DEV__) {
            __WEBPACK_IMPORTED_MODULE_0_zrender_src_core_util__["each"](mandatoryMethods, function (method) {
                if (!proto[method]) {
                    console.warn(
                        'Method `' + method + '` should be implemented'
                        + (proto.type ? ' in ' + proto.type : '') + '.'
                    );
                }

配置了 // 定义环境变量

    new webpack.DefinePlugin({
      PRODUCTION: JSON.stringify(PRODUCTION),
      DEVELOPMENT: JSON.stringify(DEVELOPMENT),
      __DEV__: false
    }),

不起作用

bxychy commented 6 years ago

@xiguayizu,@hefeng1208,@darkurse, 谢谢各位大佬。。。vue2下面是build\webpack.dev.conf.js,不是Base

cooooode commented 6 years ago

我刚才使用3.8版本,也遇到这个问题了 https://github.com/ecomfe/echarts/issues/7000, 使用老版本解决了 cnpm i echarts@3.7.2

pissang commented 6 years ago

我们在新发布的 3.8.2 中将 lib 下的重新转译成了 CommonJS 格式并且去掉了 DEV,应该解决了大家构建的兼容问题。非常抱歉新版本的模块系统给大家造成了这么大的麻烦。

chasekafei commented 6 years ago

刚升级了 3.8.2 没问题了,辛苦!

KaroseLiu commented 6 years ago

@pissang 是不是对应的像echarts-for-react,或者react-native的包他们的依赖都要更新一下,不然还是不行呢~

pissang commented 6 years ago

@KaroseLiu 应该不需要,只要不要安装到 3.8.0 就行了

bxychy commented 6 years ago

@pissang老铁。。我现在更新到3.8.2了。但是我type:line的时候报错undefined的了。

bytangyue commented 6 years ago

3.8.0版本的echarts地图都不出来,一直在报TypeError: targetList is undefined的错@pissang

cooooode commented 6 years ago
font{
    line-height: 1.7;
}
ul,ol{
    list-style-position: inside;
}

可以升级一下版本试试

    a#ntes-pcmail-signature-default:hover {
        text-decoration: underline;
        color: #199cff;
        cursor: pointer;
    }
    a#ntes-pcmail-signature-default:active {
        text-decoration: underline;
        color: #246fce;
        cursor: pointer;
    }

在2017年11月13日 17:38,raindew2016<notifications@github.com> 写道: 

3.8.0版本的echarts地图都不出来,一直在报TypeError: targetList is undefined的错

—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.