What's the point of separating the Model from the View Model? (MVVM)

前端 未结 4 1664
情歌与酒
情歌与酒 2021-01-20 03:03

I don\'t think I understand the MVVM pattern properly because having a Model and ViewModel class seems redundant to me.

My understanding of the Model is to basicall

4条回答
  •  青春惊慌失措
    2021-01-20 03:30

    The problem is that user interfaces themselves can get pretty complex. You've got widgets all over the place - sliders, text fields, buttons, checkboxes, radio buttons - and sometimes there's more to the View than just "fill in these blanks with these values from the Model". The ViewModel is a model of your data from the UI's standpoint. Usually this is a simplification of the full view, but it could also be a complication (if you have an aggregate field built up from multiple controls stored in a single attribute in the persistent store, for instance).

提交回复
热议问题