前端技能树,面试复习第 45 天—— Vue 基础 | 模版编译原理 | mixin | use 原理 | 源码解析

1. Vue template 到 render 的过程

vue的模版编译过程主要如下:template -> ast -> render 函数

vue 在模版编译版本的码中会执行 compileToFunctionstemplate 转化为 render 函数:

// 将模板编译为render函数
const {
   
    
     render, staticRenderFns } = compileToFunctions(template,options//省略}, this)

CompileToFunctions 中的主要逻辑如下∶

(1)调用 parse 方法将 template 转化为 ast(抽象语法树)

<

猜你喜欢

转载自blog.csdn.net/ImagineCode/article/details/126074509