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

var zrender=require('zrender'); 运行时报错 #70

Closed
gzhal opened this issue Jul 9, 2014 · 4 comments
Closed

var zrender=require('zrender'); 运行时报错 #70

gzhal opened this issue Jul 9, 2014 · 4 comments

Comments

@gzhal
Copy link

gzhal commented Jul 9, 2014

使用2.0版本,按下列方式一运行时会报错,错误如下:
Error: [MODULE_MISS]zrender is not exists!
throw new Error( '[MODULE_MISS]' + ids + ' is not exists!' );
按方式二,一切正常。

require只支持回调函数方式使用吗?

var fileLocation = './lib/zrender';
require.config({
    paths: {
        'zrender': fileLocation,
        'zrender/shape/Sector':fileLocation
    }
});

//方式一
var zrender=require('zrender');

//方式二
require([
'zrender',
'zrender/shape/Sector'
],function(zrender,SectorShape){
var zr = zrender.init(document.getElementById('main'));

    zr.clear();
 });
@kener
Copy link
Contributor

kener commented Jul 9, 2014

必然啊,入口地方必须回调,再次使用才能直接取

@gzhal
Copy link
Author

gzhal commented Jul 9, 2014

谢谢回复。
再问一下,如果我想简化引用,导入所有的模块,除了下面的办法外,有没有简单点的办法?
(我用的是Build过的zrender.js)

var fileLocation = './lib/zrender';
require.config({
paths: {
'zrender': fileLocation,
'zrender/shape/Sector':fileLocation,
...... //逐个模块罗列
}
});

require([
'zrender',
'zrender/shape/Sector',
.... //再逐个罗列,避免在函数中引用了未加载的模块
],function(zrender){
});

@kener
Copy link
Contributor

kener commented Jul 10, 2014

没有,这本身就是按需加载,要什么图形请求什么图形

@gzhal
Copy link
Author

gzhal commented Jul 10, 2014

明白,谢谢啦。

@gzhal gzhal closed this as completed Jul 10, 2014
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