作为 MVC 的初学者,我仍然无法理解在什么场景下我们需要使用 jQuery,jQuery 和 MVC 之间的关系。到目前为止,我注意到我们在 MVC 中大量使用 jQuery,如果没有 jQuery 知识,就不可能学习 MVC。
2 回答
The first thing you need to do is understand the difference between the server and the client.
ASP.NET MVC lives on the server. MVC is a framework for serving up web requests. You can write MVC applications that use 0 lines of JavaScript or jQuery.
The client-side JavaScript, specifically jQuery, is its own monster. jQuery provides shortcuts for working and manipulating the DOM. jQuery and JavaScript is independent of the server, and can be used with any type of web server, Microsoft stack or otherwise.
The two are very closely related because there is a lot of functionality where constant communication between the server and the client, or pages that change as the user performs various actions, is almost necessary functionality in "modern" web applications.
版本 3 中的 MVC 框架中的 jQuery 用于
- 客户端不显眼的验证
- 不显眼的阿贾克斯
它提供了一个优雅的基于 CSS 3 的语法来遍历你的 DOM,一个流畅的 API 用于操作和动画 DOM 元素,以及非常简洁的 Ajax 调用包装器——所有这些都经过精心抽象以消除跨浏览器的差异。