当前位置:网站首页>Render function and virtual DOM
Render function and virtual DOM
2022-07-04 21:03:00 【Bug pill】
render Function and virtual dom
fictitious dom
What is it? : Used to describe the dom Of js object
effect :vue Updating the real DOM front , fictitious dom Will be carried out in diff operation , Compare the virtual before and after the update DOM The different parts of the structure , Then, the asynchronous update queue is used to update the difference part to the real DOM in , Thus reducing the ultimate need to be true DOM Number of operations performed on , Improve the efficiency of page rendering
let vDom = {
tag: "div",
attributes: {
id: "vdom",
},
children: {},
};
From template to reality dom:
Templates -> Compile -> become render function -> fictitious dom -> real dom
If used directly render function , The compilation process of the template is omitted ,vue Run faster
render function
render Function is used to realize virtual dom Of
Use render Function instead of template function
No need to use vue Built in instructions , I can't use it , We can all pass native js To achieve
render Function by createElement Parameter to create a virtual dom;
createElement Constitute the vue virtual dom The template of , It has three parameters :
The first parameter is required : It could be a html label , It can also be a component or function
The second parameter is optional : Data objects , The dom Node configuration
The third parameter is optional : Group nodes
<script>
export default {
render: (createElement) => {
return createElement(
// The first parameter : Mandatory , Tag name
"div",
// The second parameter : Optional objects , Label related information
{
// And `v-bind:class` Of API identical ,
// Accept a string 、 An array of objects or strings and objects
class: {
baseClass: true,
bar: false,
},
// And `v-bind:style` Of API identical ,
// Accept a string 、 object , Or an array of objects
style: {
color: "red",
fontSize: "16px",
},
// ordinary HTML characteristic
attrs: {
id: "foo",
},
// Components prop
props: {
myProp: "bar",
},
// DOM attribute
// domProps: {
// innerHTML: ` love you `,
// },
// The event monitor is `on` Within the properties ,
// But no longer support such as `v-on:keyup.enter` Such a decorator .
on: {
click: function() {
console.log(6688);
},
},
},
// The third parameter : Optional array , Child nodes are related
[" love you !", createElement("p", [" mua "])]
);
},
};
</script>
<style lang="less" scoped>
.baseClass {
background: #ccc;
}
</style>
.baseClass {
background: #ccc;
}
</style>

边栏推荐
- colResizable.js自动调整表格宽度插件
- 阿里云国际版CDN的优势
- 阿里测试师用UI自动化测试实现元素定位
- 【申博攻略】六.如何联系心仪的博导
- Idea configuration standard notes
- What should I do if my computer sharing printer refuses access
- 网件r7000梅林系统5g不稳定 5g信号经常掉线解决方法
- Flet tutorial 07 basic introduction to popupmenubutton (tutorial includes source code)
- 网件r7000梅林系统虚拟内存创建失败,提示USB磁盘读写速度不满足要求解决办法,有需要创建虚拟内存吗??
- Remember to build wheels repeatedly at one time (the setting instructions of obsidian plug-in are translated into Chinese)
猜你喜欢

Hwinfo hardware detection tool v7.26 green version

MySQL - database query - use of aggregate function, aggregate query, grouping query
![[1200. Différence absolue minimale]](/img/fa/4ffbedd8f24c75a20d3eaeaf0430ae.png)
[1200. Différence absolue minimale]

PS竖排英文和数字文字怎么改变方向(变竖直显示)

Flet tutorial 06 basic introduction to textbutton (tutorial includes source code)

Understand Alibaba cloud's secret weapon "dragon architecture" in the article "science popularization talent"

字节测试工程师十年经验直击UI 自动化测试痛点

Hands on deep learning (III) -- convolutional neural network CNN

Quelques suggestions pour la conception de l'interface

How to solve the problem that win11 cannot write the value to the registry key?
随机推荐
测试用例 (TC)
PermissionError: [Errno 13] Permission denied: ‘data.csv‘
Pytorch---使用Pytorch实现LinkNet进行语义分割
二叉树的四种遍历方式以及中序后序、前序中序、前序后序、层序创建二叉树【专为力扣刷题而打造】
word中插入图片后,图片上方有一空行,且删除后布局变乱
Go language notes (4) go common management commands
How does win11 search for wireless displays? Win11 method of finding wireless display device
What if win11u disk refuses access? An effective solution to win11u disk access denial
MySQL --- 数据库查询 - 聚合函数的使用、聚合查询、分组查询
Remember to build wheels repeatedly at one time (the setting instructions of obsidian plug-in are translated into Chinese)
js 闭包
What if the brightness of win11 is locked? Solution to win11 brightness locking
Hash quiz game system development how to develop hash quiz game system development (multiple cases)
[micro service SCG] use of predict
After inserting a picture into word, there is a blank line above the picture, and the layout changes after deletion
Flet tutorial 04 basic introduction to filledtonalbutton (tutorial includes source code)
卷积神经网络在深度学习中新发展的5篇论文推荐
RFID仓储管理系统解决方案的优点
Jmeter 之压测入门
五子棋 上班摸鱼工具 可局域网/人机