2012-07-09 37 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

相關問題