【js】 vue 2.5.1 源码学习(十二)模板编译


大体思路(十) 本节内容: 1. baseoptions 参数分析 2. options 参数分析 3. parse 编译器 4. parseHTNL 函数解析   // parse 解析 parser--名词--解析器     ==> getShouldDecode()       inBroeser       // 监听所有的标签 //监听href       shouldDecodeNewLines / shouldDecodeNewLinesForHref       delimiters: options.delimiters //改变文本插入的分割符       comments:options.comments // 是否保留渲染模版中的注释     ==> baseOptions 解析     // 编译的步骤: 1. 语法的分析 2. 句法分析 3. 类型分析 4. 代码优化 5.代码形成   ==> function parse(template,options){     // 词法分析     parseHTML(template,{...}); // 模版字符串进行词法分析       ==> stack=[] // 存储标签名         expectHTML = oprions.expectHTML // true         ....       ==> while(html){ // 那些是标签 那些是属性 那些是指令 那些是字符串模版 jason数据       ==> isPlainTextElement       }   } 代码可以参考源码