美文网首页
为什么要有前端框架

为什么要有前端框架

作者: Camilia_yang | 来源:发表于2020-01-21 15:56 被阅读0次
    image.png

    the biggest benefit these frameworks provide: keeping the UI in sync with the state
    框架最大的优点是,保持页面(UI)和状态的同步。
    —— The deepest reason why modern JavaScript frameworks exist

    框架主要的两个策略是:
    1.重渲染整个组件,主要是利用了虚拟DOM技术(React)
    2.Observer观察者(Angular and Vue.js): 声明的变量都有一个observer,当数据变化时,页面中声明的变量所在的位置也会相应的更新

    注意,框架并不等于组件,组件只是一个自定义的Tag,它本身并没有任何保持状态和页面一致性的机制。如果你想要把组件当框架用,那你还需要引入第三方插件或者自己写“同步”机制(It’s not that hard to make your own framework using an existing Virtual DOM library. But I’m not suggesting you to do that! Virtual DOM library:Virtual DOM implementations

    Conclusion:
    The main problem modern JavaScript frameworks solve is keeping the UI in sync with the state.

    相关文章

      网友评论

          本文标题:为什么要有前端框架

          本文链接:https://www.haomeiwen.com/subject/ityezctx.html