2012-07-09 39 views

回答

7

在Web工作者中,其他脚本可以使用importScripts function加载。该source code of RequireJS表明,网络工作者也支持:

// Line 23: 
isWebWorker = !isBrowser && typeof importScripts !== 'undefined', 
// Line 1877: 
} else if (isWebWorker) { 
    //In a web worker, use importScripts. This is not a very 
    //efficient use of importScripts, importScripts will block until 
    //its script is downloaded and evaluated. However, if web workers 
    //are in play, the expectation that a build has been done so that 
    //only one script needs to be loaded anyway. This may need to be 
    //reevaluated if other use cases become common. 
    importScripts(url); 
+0

所以,仅仅是明确的......第一我叫importScripts(“require.js”);并在下一行我确实需要([...],函数(...){...}); ? – 2012-07-09 21:46:21

+0

而且,据推测,您还可以使用选项配置您的需求呼叫? – 2012-07-09 21:49:00

+0

@AndrewEisenberg'requireJS'应该包含脚本(请参阅答案中的源代码链接)。去尝试它,并报告回来;) – 2012-07-09 21:58:07

相关问题