-
Notifications
You must be signed in to change notification settings - Fork 451
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
小小的疑问 #16
Comments
Model和View不是一一对应的,一个View可对应多个model,换言之将多种结构的数据在一个视图上显示出来 |
准确的说View不能知道Model的存在,更不能知道Model存在什么属性,您目前的做法肯定是在
|
当然各有各的看法,这里只是存在疑问,就是在MVVM中。类似于cell.label.text = model.name 这样的代码,应该存在什么地方。 |
model - viewmodel - view 理想情况下view的展示内容绑定到viewmodel,viewmodel初值即界面初值由model提供,复用view实际上需要更改与之匹配的viewmodel(构造函数),如果需要做到纯净的MVVM ,则viewmodel不能有任何复杂的数据类型,最后做出来的view都是标准控件,实际应用我目前只能做到功能内分离,即一个独立功能内部做view-model隔离 |
代码写的很棒,但是确实view 和model 并没有分离,还是藕断丝连的,view 也做不到复用吧 |
为什么不在cell里面去mode化呢 |
既然MVVM是解耦View和Model之间的关系的,就是独立View和Model ,这样如果要复用这个View的时候就很方便 ,比如我把这个View拖进另外一个工程,就能使用,但是你这个工程并没有独立View和model ,在View里面直接引入Model ,你觉得这个是真正意义上的MVVM?我要复用这个View 我还要有一个一样的Model,这不是耦合吗?
The text was updated successfully, but these errors were encountered: