简体   繁体   English

在露天的另一个javascript文件中包含.js文件

[英]Include .js file in another javascript file in alfresco

I'm working with alfresco and was wondering how to include a js file in another file. 我正在与alfresco合作,想知道如何在另一个文件中包含js文件。 How do I deal with dependency when I want to use a library? 我要使用库时如何处理依赖关系?

Thanks a lot 非常感谢

As Lista suggested, I created an answer : 正如Lista所建议的,我创建了一个答案:

I think this is what you need (from Alfresco documentation ) : 我认为这是您需要的(来自Alfresco文档 ):

Importing scripts 导入脚本

This feature allows you to build libraries of scripts for use by other scripts at runtime. 此功能使您可以构建脚本库,以便在运行时供其他脚本使用。 The syntax to import the scripts is specific to Alfresco and is not a feature of standard JavaScript. 导入脚本的语法特定于Alfresco,不是标准JavaScript的功能。 For example, the syntax, as supported by most web browsers, is not part of standard ECMA JavaScript and will not work in Alfresco. 例如,大多数Web浏览器支持的语法不是标准ECMA JavaScript的一部分,并且在Alfresco中不起作用。

The syntax to import other scripts is very strict and you must follow it exactly; 导入其他脚本的语法非常严格,您必须严格遵循它。 otherwise, the import may fail. 否则,导入可能会失败。 Import directives must be the first lines in the JavaScript file. 导入指令必须是JavaScript文件中的第一行。 This means that no code or comments are allowed above those lines, and the usual JavaScript code and comments appear after the import lines. 这意味着在这些行上方不允许有任何代码或注释,并且通常的JavaScript代码和注释会出现在导入行之后。 Only the following syntax variants are supported: 仅支持以下语法变体:

  • Import a script from the repository using a name-based path: 使用基于名称的路径从存储库导入脚本:

     <import resource="/Company Home/Data Dictionary/Scripts/library.js"> 
  • Import a script from the repository using a NodeRef reference: 使用NodeRef参考从存储库导入脚本:

     <import resource="workspace://SpacesStore/6f73de1b-d3b4-11db-80cb-112e6c2ea048"> 
  • Import a script from a Java classpath location: 从Java类路径位置导入脚本:

     <import resource="classpath:alfresco/extension/myutils.js"> 

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM