更好的地方将js代码放在MVC中 [英] Better place to place js code in MVC

查看:67
本文介绍了更好的地方将js代码放在MVC中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



可以建议我们最好的做法是在MVC中保存JS代码。

目前我发现很多应用程序JS代码在.cshml中写入



例如

Hi All,

Can any suggest we best practice to save JS code Area wise in MVC.
currently I found in many application JS code is writtern in .cshml

E.g.

E:.
├───Controllers
├───Models
└───Views
    ├───Listserv
    └───Shared





所有JS代码都在.cshtml中找到



我可以明智地创建专用的JS区域吗?这里有最佳实践建议吗?

提前致谢。

问候,

Sanjay



我尝试了什么:



目前为止没有任何内容。我只是看看各种项目。



All JS code is find in .cshtml

Can I crate dedicated JS Area wise? Any best practice suggestion here?
Thanks in advance.
Regards,
Sanjay

What I have tried:

No nothing so far. I am just look at various projects.

推荐答案

@
David_Wimbley



添加在


Adding that in

BundleConfig.cs

你不认为当这些脚本实际上不需要时会添加吗?



假设我有账户和两个配置文件功能js是不同的。

如果我添加然后在

don't you think that will added when those script are actually not required?

Assume I have "Account" & "Profile" functionality js for both is different.
If I add then in

BundleConfig

将不会同时加载两个js我可能不需要两者同时。

won't both js get loaded where I might not need both at same time.


这篇关于更好的地方将js代码放在MVC中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆