美文网首页
vue引入echart常见问题

vue引入echart常见问题

作者: yfmei | 来源:发表于2018-07-13 20:03 被阅读0次

    导入echart正常,导入china.js就报错

    • 原因是china.js里面导入echart的方法,在webpack中都无效所致,修改如下即可:
    (function (root, factory) {
        if (typeof define === 'function' && define.amd) {
            // AMD. Register as an anonymous module.
            define(['exports', 'echarts'], factory);
        } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
            // CommonJS
            factory(exports, require('echarts'));
        } else {
            // Browser globals
            factory({}, root.echarts);
    
        }
    }(this, function (exports, echarts) {
        var log = function (msg) {
            if (typeof console !== 'undefined') {
                console && console.error && console.error(msg);
            }
        }
        if (!echarts) {
          echarts = require('echarts/lib/echarts') // TODO 上述方法都无法引入echart,这里再导一遍
        }
    
        if (!echarts) {
            log('ECharts is not Loaded');
            return;
    
        }
        if (!echarts.registerMap) {
            log('ECharts Map is not loaded')
            return;
        }
        echarts.registerMap('china', 
    

    相关文章

      网友评论

          本文标题:vue引入echart常见问题

          本文链接:https://www.haomeiwen.com/subject/skvspftx.html