当前位置:网站首页>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>
边栏推荐
- Hash quiz game system development how to develop hash quiz game system development (multiple cases)
- HMS Core 统一扫码服务
- 仿ps样式js网页涂鸦板插件
- MySQL --- 数据库查询 - 聚合函数的使用、聚合查询、分组查询
- word中插入图片后,图片上方有一空行,且删除后布局变乱
- Vue cleans up the keepalive cache scheme in a timely manner
- In the face of the same complex test task, why can the elder sort out the solution quickly? Ali's ten-year test engineers showed their skills
- RFID仓储管理系统解决方案的优点
- uniapp 富文本编辑器使用
- What should I do if my computer sharing printer refuses access
猜你喜欢
Some suggestions for interface design
伦敦银走势图分析的新方法
How does the computer save web pages to the desktop for use
网件r7000梅林系统5g不稳定 5g信号经常掉线解决方法
LeetCode+ 81 - 85 单调栈专题
网络命名空间
What if the win11 shared file cannot be opened? The solution of win11 shared file cannot be opened
TweenMax表情按钮js特效
6月“墨力原创作者计划”获奖名单公布!邀您共话国产数据库
【1200. 最小絕對差】
随机推荐
Quelques suggestions pour la conception de l'interface
Leetcode+ 81 - 85 monotone stack topic
Why is TCP three handshakes and four waves
Idea plug-in
测试员的算法面试题-找众数
How does the computer save web pages to the desktop for use
Jmeter 之压测入门
[server data recovery] a case of RAID5 data recovery stored in a brand of server
word中使用自动插入题注功能
How does win11 search for wireless displays? Win11 method of finding wireless display device
How to solve the problem that win11 cannot write the value to the registry key?
Summary of the mistakes in the use of qpainter in QT gobang man-machine game
Record the online bug solving list (unfinished to be continued 7/4)
HMS Core 统一扫码服务
The concept and application of hash table
acwing 3302. Expression evaluation
Hash quiz game system development how to develop hash quiz game system development (multiple cases)
扩展你的KUBECTL功能
【解决方案】PaddlePaddle 2.x调用静态图模式
How does wincc7.5 SP1 find variables and their positions through cross indexing?