MVC问题:直接模型-查看交流-为什么? [英] MVC question: direct modell <-> view communication - why?

查看:73
本文介绍了MVC问题:直接模型-查看交流-为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我,为什么要在MVC模式中直接与视图进行模型通信,为什么不通过控制器呢?

can anybody tell me, why communicates the model direct with the view in the MVC pattern, and why not just throught the controller?

http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

推荐答案

有时使用Controller进行简单的View/Model通讯成本太高.

Sometimes it is too costly to use Controller for simple View/Model communication.

如果您的视图仅显示原始数据而没有任何操作(过滤,可视化,修改...),则很容易忘记Controller.

If your view just shows raw data without any operation (filtration, visualization, modification ...) it is easy to forget about Controller.

但是这种行为非常容易被滥用 .

But this behavior is so abuse-able sometimes it kills all of the advantages of MVC.

这是 MVP 出现的位置:

MVP(Model-View-Presenter)切断了模型与视图之间的联系,所有事物都通过中间人(Presenter)传递.

MVP (Model-View-Presenter) cuts the connection between model and view and every thing pass through man-in-the-middle (Presenter).

这篇关于MVC问题:直接模型-查看交流-为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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