javascript - 导入纯 JS 文件
问题描述
我试图让我的文件尽可能基本。因此,在我的 html 文件中,我有:
<script src="js/binarytree_standardgrid_script.js"></script>
然后在我的binarytree_standardgrid_script.js
文件中我想使用:Ramda.js
如何在不使用节点的情况下“导入”Ramda.js
或“包含” ?Ramda.js
还是我真的需要使用节点?
然后我有另一个文件叫做BinaryTree.js
文件结构为
./index.html
./algorithms/BinaryTree.js
./js/binarytree_standardgrid_script.js
在我调用的html文件中binarytree_standardgrid_script.js
:
在该脚本中,我希望能够使用BinaryTree.js
,然后还可以使用 Ramda 库。
我怎样才能在 Javascript 中做到这一点?我真的需要使用节点吗?
解决方案
好的,我找到了解决方案:
只需将脚本放在 html 页面上:
<script src="algorithms/BinaryTree.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
<script src="js/binarytree_standardgrid_script.js"></script>
只要不在函数内,这些类和函数就可以在脚本文件中使用。
推荐阅读
- java - 如何使用 GSSAPI 将 java swing 应用程序连接到 mariadb DB?
- swift - 为什么没有在 UITabBarController 上调用 deinit?
- android - 将单个 API 响应转换为地图列表以在颤动中转换为卡片
- azure - Ansible - 标记 Azure 运行的虚拟机
- elasticsearch - 将地理边界框扩展 x 英里的计算
- java - Spring Security OAuth 2 资源服务器:为 jwt 验证转换 jwks 不支持 use==enc
- reactjs - Enzyme Shallow 不渲染组件,输出为
- python - 如何从 RPGLE 调用 Python 并返回一个值?
- reactjs - React Router:子组件中定义的路由不起作用
- javascript - 从 Mongoose 获取数据