如何将 extjs4 文件分离到相关包中
有一个带有 extjs4 前端的 symfony 2 项目。我从一个 extjs 包开始,它现在包含整个 extjs 应用程序。问题是随着项目的增长,管理将变得困难。
我认为,最好的解决方案是将所有 extjs 文件重新定位到相关的包
(例如:将所有表单、面板、网格等添加到 UserBundle 中)并使用中央 Extjs 包来加载它们。
以这种方式组织项目的最佳实践是什么?
以及如何包含另一个包中的 js 文件?
或者我应该为每个包创建 extjs 应用程序(我不确定这是否明智)?
There is a symfony 2 project with extjs4 frontend. I started with an extjs bundle which contains now the entire extjs app. The problem is it will be difficult to manage as the project grows.
I think , the best solution would be to relocate all extjs file to the related bundle
(e.g.: to the UserBundle all forms, panel, grid etc. ) and use a central Extjs bundle to load them.
What is the best practice to organize a project in this manner?
And how to include the js files from another bundle?
Or should I create extjs app to every bundle (I'm not sure it would be wise) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定这是否是最佳实践,但我知道这适用于 ExtJs 4.0.7。
例如,我有以下文件夹结构:
因此,在 app.js 中,我有以下代码:
在 SimpleIFrame 中,我有以下代码:
那么稍后在 app.js 中,我可以执行以下操作:
这允许我分离整个应用程序.js 分成单独的文件。直到我弄清楚这一点之前,我一直收到可怕的消息:
这只是意味着我忘记调用 Ext.Loader.setPath。
现在不要在接下来的部分引用我,但似乎如果您删除 Ext.require 然后 SimpleIFrame.js 被加载到全局命名空间中,这不是你真正想要的,但它仍然被加载,并且它确实工作,这是更重要的。
希望有帮助。请注意,我很可能都是错的;),并且就我而言,我很幸运;我能做什么,我还是个n00b。
I'm not sure this is best practice, but I know this works on ExtJs 4.0.7.
So for example I have the following folder structure:
So in app.js I have the following code:
In SimpleIFrame I have the following code:
So then later in app.js I can do the following:
That allows me to separate the whole app.js into separate files. Up until I figured this out I kept getting the dreaded:
Which just meant that I'd forgotten to call Ext.Loader.setPath.
Now don't quote me on this next bit, but it seems that if you remove the Ext.require then SimpleIFrame.js is loaded in the global namespace, which is not really what you want, but it's still loaded, and it does work, which is more important.
Hope that helps. And mind you I will be most likely all be wrong ;), and had just gotten lucky in my case; what can I do, I'm still a n00b.
您可以将 JS 文件与每个文件的 Resources/public/js 中的文件分开打包。
然后,在您的主 html 模板上,您可以使用 assetic 包含所有 JS 文件。
You could make separates bundles with your JS files inside Resources/public/js of each of them.
Then, on your main html template you could include all your JS Files using assetic.