本文介绍了MVC与助焊剂?双向还是单向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看下图(解释了MVC),我看到了单向数据流.

Looking at the following diagram (which explains MVC), I see unidirectional data flow.

那么为什么我们认为MVC在证明Flux的同时具有双向数据流?

So why do we consider MVC to have bidirectional data flow while justifying Flux ?

推荐答案

由于在Javascript框架中,MVC无法按照您所描述的方式工作. UI通常与模型进行双向通信,如下所示:

Because in Javascript frameworks the MVC does not work the way you depicted. The UI generally communicates bi-directionally with the model, as in:

  1. 用户类型输入View输入
  2. MVC框架绑定onchange()来更新模型.
  3. Ajax请求引入了新的模型数据.
  4. MVC框架更新View输入的值以匹配模型.

在Flux架构中,UI只会将带有类型和相关数据的独立动作触发给调度程序,然后调度程序将以任何后台ajax方法更新模型的方式来更新模型.

In Flux architecture, the UI would only fire an independent action with type and associated data to a dispatcher which would then update the model the same way any background ajax method would update the model.

参考: http://www.thesoftwaresimpleton.com/blog/2013/03/23/client-side-mvc/

我们正在建立两个对象之间的双向通信..."

"We are setting up a two way communication between two objects..."

简而言之,我们将firstName属性的值连接在一起 对象对象到输入的value属性."

"In short we are wiring together the value of the firstName property of the Person object to the value property of the input."

http://guides.emberjs.com/v1.10.0/object -model/bindings/

这篇关于MVC与助焊剂?双向还是单向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 23:39