(el, state)
| 14818 | // 详细:只渲染元素和组件一次。随后的重新渲染,元素/组件及其所有的子节点将被视为静态内容并跳过。这可以用于优化更新性能。 |
| 14819 | |
| 14820 | function genOnce(el, state) { |
| 14821 | //标志已经处理过的 |
| 14822 | el.onceProcessed = true; |
| 14823 | if (el.if && !el.ifProcessed) { |
| 14824 | //判断标签是否含有if属性 |
| 14825 | return genIf(el, state) |
| 14826 | } else if (el.staticInFor) { |
| 14827 | var key = ''; |
| 14828 | var parent = el.parent; |
| 14829 | while (parent) { |
| 14830 | if (parent.for) { |
| 14831 | key = parent.key; |
| 14832 | break |
| 14833 | } |
| 14834 | parent = parent.parent; |
| 14835 | } |
| 14836 | if (!key) { |
| 14837 | "development" !== 'production' && state.warn( |
| 14838 | "v-once can only be used inside v-for that is keyed. " |
| 14839 | ); |
| 14840 | //genElement根据el判断是否是组件,或者是否含有v-once,v-if,v-for,是否有template属性,或者是slot插槽,转换style,css等转换成虚拟dom需要渲染的参数函数 |
| 14841 | return genElement(el, state) |
| 14842 | } |
| 14843 | //genElement根据el判断是否是组件,或者是否含有v-once,v-if,v-for,是否有template属性,或者是slot插槽,转换style,css等转换成虚拟dom需要渲染的参数函数 |
| 14844 | return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")") |
| 14845 | } else { |
| 14846 | //将子节点导出虚拟dom 渲染函数的参数形式 |
| 14847 | return genStatic(el, state) |
| 14848 | } |
| 14849 | } |
| 14850 | |
| 14851 | //判断标签是否含有if属性 解析 if指令中的参数 并且返回 虚拟dom需要的参数js渲染函数 |
| 14852 | function genIf( |
no test coverage detected