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

Posted 前端修罗场

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了前端技能树,面试复习第 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(抽象语法树)

<

以上是关于前端技能树,面试复习第 45 天—— Vue 基础 | 模版编译原理 | mixin | use 原理 | 源码解析的主要内容,如果未能解决你的问题,请参考以下文章