Giter Club home page Giter Club logo

fed-e-task-part3-02's Introduction

简答题

  1. Vue 首次渲染的过程。
    1. 先初始化Vue的实例成员和静态方法
    2. 调用构造函数,根据模板或用户自己写的render函数生成渲染函数
    3. 调用beforeMount钩子函数
    4. 根据渲染函数生成虚拟DOM,再将虚拟DOM转换成真实DOM,挂载到页面上
    5. 创建Watcher对象,收集依赖,以便将来数据改变时更新视图
    6. 调用Mounted钩子函数,初始化结束
  2. Vue 响应式原理
    1. 通过Object.defineProperty 和 ES6 的 Proxy 对对象类型的数据进行数据劫持,监听数据的变化
    2. 在getter函数中收集依赖
    3. 通过发布订阅模式在数据改变,调用setter时,更新视图
  3. 虚拟 DOM 中 Key 的作用和好处
    1. 作用:标记Vnode,结合tagName用来判断新旧节点是否是同一节点
    2. 好处:当更改视图相关数据时,最小化更新视图,性能更好
  4. Vue 中模板编译的过程
    1. 将模板字符串转换成AST抽象语法树
    2. 对AST进行静态节点标记,在后续转化过程中提供优化
    3. 通过 generate 将 AST 抽象语法树转换为 render 函数的 js 字符串

fed-e-task-part3-02's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.