Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教一下为何叫MVVM,而不是MVVC? #1

Open
pangpingfei opened this issue Jan 22, 2016 · 9 comments
Open

请教一下为何叫MVVM,而不是MVVC? #1

pangpingfei opened this issue Jan 22, 2016 · 9 comments

Comments

@pangpingfei
Copy link

到底是哪几个单词?不是Model,View,ViewModel,Controller么?

@lovemo
Copy link
Owner

lovemo commented Jan 22, 2016

你可以看看这段文字,讲解的很详细:
MVVM是一定需要Controller的参与的,虽然MVVM在一定程度上弱化了Controller的存在感,并且给Controller做了减负瘦身(这也是MVVM的主要目的)。但是,这并不代表MVVM中不需要Controller,MMVC和MVVM他们之间的关系应该是这样:
View <-> C <-> ViewModel <-> Model,所以使用MVVM之后,就不需要Controller的说法是不正确的。严格来说MVVM其实是MVCVM。从图中可以得知,Controller夹在View和ViewModel之间做的其中一个主要事情就是将View和ViewModel进行绑定。在逻辑上,Controller知道应当展示哪个View,Controller也知道应当使用哪个ViewModel,然而View和ViewModel它们之间是互相不知道的,所以Controller就负责控制他们的绑定关系,所以叫Controller/控制器就是这个原因。

@pangpingfei
Copy link
Author

那还是不明白第二个M是指什么?

@lovemo
Copy link
Owner

lovemo commented Jan 22, 2016

M:model(模型);
VM:ViewModel(用于Controller减负瘦身)

@pangpingfei
Copy link
Author

哦,原来如此~~谢谢!

@lovemo
Copy link
Owner

lovemo commented Jan 22, 2016

呵呵,不用谢,交流才有进步嘛

@pangpingfei
Copy link
Author

嗯! 有q群或者qq加个嘛,谢谢!5665627

@lovemo
Copy link
Owner

lovemo commented Jan 22, 2016

更新了qq群信息,OC版里有,Swift忘记更新了

@lovemo lovemo closed this as completed Jan 22, 2016
@lovemo lovemo reopened this Jan 22, 2016
@leedaihung
Copy link

其实MVVM框架里面出现Controller不会很奇怪吗?

@GuangLinLau
Copy link

MVVM是从微软的WPF技术衍变而来的,MVVM之前有MVP 目的都是达到视图 模型分离的作用,P也就相当于VM,把一些事件和请求放到VM,这样达到瘦身Controller的目的,Controller的特性在iOS上是不可能缺少的,就跟Android的Activity是一样的。所以我们只要用了MVVM的特性 结合开发平台和项目本身做相应的修改,有句话说,适合自己的才是最好的。以上个人见解。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants