简体   繁体   English

木偶模块和RequireJS模块

[英]Marionette modules and RequireJS modules

I read a few posts here, and on the web in general. 我在这里以及一般在网上阅读了几篇文章。 People don't recommend using both in the same project. 人们不建议在同一项目中同时使用两者。 However what I'm trying to get out of require with my marionette application is not having multiple script tags on the html page, and not worrying about the order js files are loaded. 但是,我在木偶应用程序中想要摆脱的需求是在html页面上没有多个脚本标签,也不必担心js文件的加载顺序。 Can marionette accomplish this ? 木偶能否做到这一点? Please, I'd be grateful if someone could also recommend few articles on the topic. 请,如果有人也可以推荐有关该主题的几篇文章,我将不胜感激。

I do recommend using Marionette and RequireJS. 我建议使用Marionette和RequireJS。 If you can use Require with backbone, you can use it with Marionette as well. 如果您可以将Require与主干一起使用,那么您也可以将其与Marionette一起使用。 Since Marionette doesn't have a script loader by default it's wise to have one. 由于木偶默认情况下没有脚本加载器,因此最好使用一个。 In my current project I have over 20 JS files and not having a script load would turn my project into a huge mess. 在我当前的项目中,我有20多个JS文件,而没有加载脚本会使我的项目陷入混乱。

What you should consider is the scope of your application. 您应该考虑的是应用程序的范围。 If it's likely that it will grow beyond 500 lines of code, consider a script loader. 如果它可能增长到超过500行代码,请考虑使用脚本加载器。

It's in the official docs: 在官方文档中:

https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs

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

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