怎么用require.js加载echart.js?


echart.js所谓的AMD模块加载真心搞不懂,用require.js加载不了。求高手解答。

前端 echarts JavaScript 前端开发

高呼吾名零娘娘 10 years, 7 months ago

可以把echarts当做一个package


 js


 require.config({
    baseUrl: '/j/pj/',
    packages: [
        {
            name: 'echarts',
            location: 'vendor/echarts',
            main: 'echarts'
        },
        {
            name: 'zrender',
            location: 'vendor/zrender', // zrender与echarts在同一级目录
            main: 'zrender'
        }
    ]
})

//在文件中使用

define(['echarts', 'echarts/chart/bar'], function(ec) {})

精肛互撸娃. answered 10 years, 7 months ago

niphor answered 10 years, 7 months ago

Your Answer