简体   繁体   English

在服务器端环境或命令行环境中,将一个javascript文件“包含”到另一个

[英]“Include” one javascript file to another one in serverside environment or in commandline environment

I have one "Test1.js" JavaScript file which will be running continuously. 我有一个“ Test1.js” JavaScript文件,它将连续运行。 I have another "Test2.js" JavaScript file which I will update periodically. 我还有另一个“ Test2.js” JavaScript文件,该文件将定期更新。 I want to call a dynamically created Test2.js JavaScript function from Test1.js file. 我想从Test1.js文件调用动态创建的Test2.js JavaScript函数。

Any help appreciated. 任何帮助表示赞赏。

You should require functions after when all scripts will be upload. 上传完所有脚本后,您应该需要功能。 So, for example in Test1.js 因此,例如在Test1.js中

window.addEventListener('load', function () {
    bar();
}, false);

In Test2.js Test2.js中

function bar() {
    alert('This is function BAR');
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Javascript / Regex:Expression在一个环境中工作,而不是在另一个环境中工作 - Javascript/Regex: Expression works in one environment and not another 仅在一种环境中执行javascript - Execute javascript only in one environment RangeError:一个环境中无效的数组长度,但另一环境中无效 - RangeError: Invalid array length in one environment but not another 我可以在运行时将JavaScript文件包含在另一个中吗? - Can I include a JavaScript file inside another one at runtime? Assetic:如何仅在开发环境中包含javascript文件? - Assetic: how to include javascript file only for dev environment? 生产环境中缺少javascript_include_tag文件(404) - javascript_include_tag file is missing on the production environment ( 404 ) 在 React-Native 中,如何根据我的环境文件选择资产文件夹而不是另一个文件夹? - In React-Native, how can I choose an assets folder instead of another one based on my environment file? Javascript:如何在另一个字符串中包含字符串文字? - Javascript: how to include a string literal into another one? 为什么我的代码可以在一种环境中工作,而不能在另一种环境中工作? - Why does my code work in one environment, but not in another? jQuery UI:在一种环境中,但在另一种环境中,“未捕获的语法错误:意外的令牌&lt;” - jQuery UI: “Uncaught Syntax Error: Unexpected token <” in one environment, but not another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM