gpt4 book ai didi

javascript - 组织脚本的优雅方式包括?

转载 作者:行者123 更新时间:2023-11-30 10:03:36 24 4
gpt4 key购买 nike

我将 Cordova 与 Angular 和 Ionic 结合使用来开发独立于平台的移动应用程序。今天了解到,对于大型项目,设置这样的项目文件夹非常聪明:

root
index.html
modules
app.js
module_1
module_1.js
module_1.html
module_2
module_2.js
module_2.html
module_2_sub
module_2_sub.js
module_2_sub.html
...

然后您像这样定义您的 App.js:

angular.module('App', ['App.Module_1', 'App.Module2'])

但是如果你有一个大项目,这会导致在 index.html 中包含一个非常庞大的脚本列表:

<script src="modules/app.js"></script>
<script src="modules/module_1/module_1.js"></script>
<script src="modules/module_2/module_2.js"></script>
<script src="modules/module_2/module_2_sub/module_2_sub.js"></script>
....

有没有更聪明的方法来组织这个脚本包含?也许像只包含 app.js 和在 app.js 中包含所有其他需要的脚本。

当然有人会说“你为什么要关心这个?”但我觉得在 index.html 中包含这么多内容并不是很“好看”。

最佳答案

你用 grunt 还是 gulp?因为我可以向您推荐这个插件 https://www.npmjs.com/package/grunt-include-source自动将源代码包含在您的主 html 中。如果您决定缩小您的来源,那么包含 .min 可能会更容易

关于javascript - 组织脚本的优雅方式包括?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30426006/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com