Skip to content

index

周边

pinia

运行时 v.s. 构建时

https://cn.vuejs.org/v2/guide/installation.html#%E5%AF%B9%E4%B8%8D%E5%90%8C%E6%9E%84%E5%BB%BA%E7%89%88%E6%9C%AC%E7%9A%84%E8%A7%A3%E9%87%8A

也就是html => virtual dom的编译是运行时做还是构建时做

因为运行时版本相比完整版体积要小大约 30%,所以应该尽可能使用这个版本。如果你仍然希望使用完整版,则需要在打包工具里配置vue的别名。因为默认引入的vue是

"main": "dist/vue.runtime.common.js",
"module": "dist/vue.runtime.esm.js", 

另外,vue1还是用的运行时用fragmentDocument去替换模板的方式,所以严格意义上而言,vue1到vue2是完整的跃进。

前者还是原来模板渲染的思想,而后者则意味着virtual dom了。

Vue v.s. React

"Vue automatically performs optimizations to update specific parts of the component tree but doesn’t offer a manual way to prevent re-renders. In React, it’s up to the developer to decide when and where to manually prevent them."

也就是vue会控制要重新渲染dom数的哪一部分 但react可能会把选择权更多的交给使用者

Vuex v.s. Redux

其实我感觉两者大差不差。不同点有二:

  • vuex是主动更改,而redux是返回新的完整结构(检测方式不同所致)
  • vuex的mutations+actions = redux的 reducer+redux-thunk //真的一模一样。如果redux不苛求它的返回纯函数的思路的话,也完全可以让actions支持异步。

"在有限程度上,React + Mobx 也可以被认为是更繁琐的 Vue,所以如果你习惯组合使用它们,那么选择 Vue 会更合理。"