MVC中的视图和模型之间的通信 [英] Communication between the View and Model in MVC

查看:97
本文介绍了MVC中的视图和模型之间的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从许多不同的来源阅读后,我对View和Model如何以MVC模式进行通信感到非常困惑.据我了解,此帖子的接受答案 Apple的这篇文章表示两者之间的通信应通过控制器完成.当 Wikipedia中的MVC页面时, ASP.NET MVC页,和此处的答案,苹果公司的文章是什么指的是实际上MVP不是MVC呢?谢谢您的帮助!

After reading from many different sources, I am very confused about how View and Model should communicate in the MVC pattern. To my understanding, the accepted answer of this post and this article from Apple are saying the communication of the two should be done through controller. While the MVC page in Wikipedia, the ASP.NET MVC page, and this article in MSDN are showing there is a direct association between View and Model. So according to the answer in here, what the article from Apple is referring to is actually MVP not MVC then? Thank you for any help!!

推荐答案

答案不只一个. 最终,您可以根据自己的需要做任何事情. 我使用控制器+ ViewModels连接到视图. 视图从不使用模型.就是控制器给他的东西.

There is more than one answer. Eventually you can do whatever you thing suits your needs. I use a controller + ViewModels to connect to the view. The view never use the model. just what the controller gives him.

史蒂芬·桑达森(Steven Sandarson)第49页中对所有模型都有很好的解释 (MVC的变体).

There is a nice explanation of all models in steven sandarson book, Page 49 (variation on MVC).

这篇关于MVC中的视图和模型之间的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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