my 的一部分main.js包含以下功能:
function isTrue(x){...}
function resizeEditors() {...}
function updateLayout() {...}
function prettify() {...}
function setTheme(theme) {...}
function themedLayout(isDark){...}
function enablePanel(panel) {...}
function disablePanel(panel) {...}
function enableDefaultPanels() {...}
function toggleFullscreen() {...}
function toggleEditorFullscreen(selected) {...}
有没有办法让这些函数对我main.js的文件的依赖项可用?
例如,在editors.js我正在使用该isTrue函数但 editors.js 模块当前无法找到isTrue,因为它在main.js文件中
editors.setShowPrintMargin( isTrue( settings.showPrintMargin ) );
编辑:
项目的样子:
main.js:
require(['jquery', 'appSession', 'editors'], function ($, appSession, editors) {
function isTrue(x){...}
function resizeEditors() {...}
function updateLayout() {...}
function prettify() {...}
function setTheme(theme) {...}
function themedLayout(isDark){...}
function enablePanel(panel) {...}
function disablePanel(panel) {...}
function enableDefaultPanels() {...}
function toggleFullscreen() {...}
function toggleEditorFullscreen(selected) {...}
});
editors.js:
define(['jquery', 'appSession'], function($, appSession){
...
editors.setShowPrintMargin( isTrue( settings.showPrintMargin ) );
...
return editors;
});