结合vue、react、angular简谈MVC、MVVM框架

React
如其官方介绍:React - A JavaScript library for building userinterfaces, React是一个为数据提供渲染为HTML视图的开源JavaScript库。从这个定义来看,可以发现React是一个View层,它的作用是提供了一套数据机制。用了virtual dom,属于facebook公司的

vue的官方文档是说vue的核心库也只是关注视图(View)层。
在这里插入图片描述

所以,实际上来说,和angular有完整的解决方案不同,狭义的vue.js和react.js实际上只是library,还并不是一个framework,因为他们没有一整套的解决方案,属于一种“小而美”框架

换句话来说,现在我们所讨论的vue、react,都是我们将他们武装之后,他们有了一整套解决方案了。成为了一个框架,我们再来讨论他们的架构模式,属于一种“大而广”框架。
在这里插入图片描述

Vue

个人认为,这是毫无争议的一个MVVM框架,对MVVM理念的贯彻也是最显而易见的。
关于渐进式框架的理解
https://baijiahao.baidu.com/s?id=1647203004323024188&wfr=spider&for=pc

Model层:接口层,原始数据模型。

View层:视图层,template中的html代码。

ViewModel层:基于一个html元素构建的vue实例。将Model中的原始数据模型,构建成一份View层可以使用的视图模型。这个时候,Model层、View层完全解耦。开发者已经完全不需要顾及View的展示更新了,只需要专注业务逻辑以及ViewModel层与Model的交互逻辑就ok。

AngularJs

Model层:接口层,原始数据模型。

View层:html页面。

ViewModel层:基于ng-app构建的应用实例,与vue类似,数据双向绑定机制不同。

React

Model层:接口层,原始数据模型。

View层:编译之后的Dom。

ViewModel层:基于jsx语法,以及react构建的VDom,单向数据流。

这么一看,vue、react、angularJS不就都是MVVM框架吗?唯一的区别就是,VM层中的Model与View,vue与angular是数据双向绑定,而react由于是单向数据流,所以需要手动更改状态。
参考链接:
https://zhuanlan.zhihu.com/p/76988636
https://zhuanlan.zhihu.com/p/64257809
其他的参考链接:
https://www.cnblogs.com/zhouyangla/p/6936455.html
https://blog.csdn.net/qq_18832439/article/details/51038454
https://www.jianshu.com/p/11c89d58d5d5
https://blog.csdn.net/qq_36228442/article/details/79470408

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue, React, and Angular are all popular JavaScript frameworks used for building web applications. Vue is a relatively lightweight framework that is known for its simplicity and ease of use. It is often favored by developers who are new to JavaScript frameworks or who prefer a more minimalist approach to development. Vue also has a strong focus on performance and can be used for building both small and large-scale applications. React is developed and maintained by Facebook and is widely used for building complex user interfaces. It uses a virtual DOM and a one-way data flow model which enables it to efficiently manage state and handle large amounts of data. React can be used with other libraries and frameworks, making it highly flexible and customizable. Angular is a full-featured framework developed by Google. It is known for its powerful features and its ability to handle large and complex applications. Angular uses a two-way data binding approach and has a steep learning curve compared to Vue and React. However, it offers a wide range of features, including dependency injection, routing, and animations, making it a popular choice for enterprise-level applications. Ultimately, the choice between Vue, React, and Angular will depend on the specific needs and preferences of the developer or development team. Each framework has its own strengths and weaknesses, and the decision should be based on the project requirements, available resources, and the experience level of the developers involved.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值