与 asp.net MVC3 和淘汰赛 js 库一起使用的最佳 ViewModel javascript 文件组织是什么?
我正在考虑将特定的 javascript ViewModel 文件添加到每个视图文件夹中,但似乎 asp.net MVC 不允许这样做,我应该对 web.config 进行一些调整。我在网上找到的其他选项是将 javascript 放入部分视图或 /Scripts 文件夹中。
您有哪些建议和想法?
I am thinking to add the specific javascript ViewModel files into each view folder, but it seems asp.net MVC doesn't allow it and I should do some tweaks on the web.config. Other options I've found online is to put the javascript into partial views, or into the /Scripts folder.
Which are your recommendation and thoughts ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将它们放在脚本文件夹中,并在脚本文件夹中有一个 js 的子文件夹结构,其中包含控制器、模型和 viewModel 文件夹
I would put them in the scripts folder and have a sub folder structure for js with controller, model and viewModel folders in the script folder
您是否考虑过使用建议的文件夹结构并创建一些命名约定? MVC 文件夹结构是一种约定。如果您遵循该约定,那么其他开发人员会发现更容易理解您的项目。
我建议为您的 java 脚本文件创建一个命名约定。例如,我可能有一个用于显示客户详细信息的视图 -
Customer\Details.cshtml
。然后,我将 java 脚本文件添加到默认的 Scripts 文件夹中并将其命名为MyProject.Customer.Details.js
另外我可能是错的,但我猜您指的是视图,而不是视图模型。Have you considered using proposed folder structure and creating some naming conventions? MVC folder structure is kind of convention. If you follow that convention, then other developers will find it easier to understand your project.
I would suggest creating a naming convention for your java script files. For example, I might have a view for displaying customer details -
Customer\Details.cshtml
. I would then add java script file into default Scripts folder and name itMyProject.Customer.Details.js
Also I might be wrong, but I guess that you are referring to a view, rather then a view model.