关于vue3:Vue设计与实现笔记持续更新

5次阅读

共计 580 个字符,预计需要花费 2 分钟才能阅读完成。

一、框架设计概览

申明式与命令式(Declarative vs Imperative)

申明式和命令式是两种编程范式。vue/react 是申明式的,jquery 那样间接操作 dom 是命令式

Alright here’s a metaphor.
Declarative Programming is like asking your friend to draw a landscape. You don’t care how they draw it, that’s up to them.
Imperative Programming is like your friend listening to Bob Ross tell them how to paint a landscape. While good ole Bob Ross isn’t exactly commanding, he is giving them step by step directions to get the desired result.

申明式就像你通知你敌人画一幅画,你不必去管他怎么画的细节
命令式就像依照你的命令,你敌人一步步把画画进去

换言之

  • 命令式编程:命令“机器”如何去做事件(how),这样不论你想要的是什么(what),它都会依照你的命令实现。
  • 申明式编程:通知“机器”你想要的是什么(what),让机器想出如何去做(how)。

在放弃可维护性的同时让性能损失最小化。

Vue3 的设计思路

二、响应式零碎

正文完
 0