当前位置:网站首页>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>
边栏推荐
- Managed service network: application architecture evolution in the cloud native Era
- 阿里测试师用UI自动化测试实现元素定位
- 托管式服务网络:云原生时代的应用体系架构进化
- Idea case shortcut
- 面对同样复杂的测试任务为什么大老很快能梳理解决方案,阿里十年测试工程师道出其中的技巧
- Reinforcement learning - learning notes 2 | value learning
- Jmeter 之压测入门
- 仿ps样式js网页涂鸦板插件
- acwing 3302. 表达式求值
- NetWare r7000 Merlin system virtual memory creation failed, prompting that the USB disk reading and writing speed does not meet the requirements. Solution, is it necessary to create virtual memory??
猜你喜欢
托管式服务网络:云原生时代的应用体系架构进化
heatmap.js图片热点热力图插件
What if the computer page cannot be full screen? The solution of win11 page cannot be full screen
Leetcode+ 81 - 85 monotone stack topic
[observation] Lenovo: 3x (1+n) smart office solution, releasing the "multiplier effect" of office productivity
What should I do if my computer sharing printer refuses access
NetWare r7000 Merlin system virtual memory creation failed, prompting that the USB disk reading and writing speed does not meet the requirements. Solution, is it necessary to create virtual memory??
How to solve the problem that win11 cannot write the value to the registry key?
idea配置标准注释
[server data recovery] a case of RAID5 data recovery stored in a brand of server
随机推荐
Browser render page pass
Quelques suggestions pour la conception de l'interface
Advantages of semantic tags and block level inline elements
托管式服务网络:云原生时代的应用体系架构进化
【微服务|SCG】Predicate的使用
Idea case shortcut
测试员的算法面试题-找众数
多模輸入事件分發機制詳解
Nmap scan
Gobang go to work fishing tools can be LAN / man-machine
Reinforcement learning - learning notes 2 | value learning
Idea restore default shortcut key
word中使用自动插入题注功能
JS closure
Golang中UTF编码和字符集
The concept and application of hash table
How does win11 search for wireless displays? Win11 method of finding wireless display device
BFC interview Brief
Alibaba testers use UI automated testing to achieve element positioning
What if the WiFi of win11 system always drops? Solution of WiFi total drop in win11 system