The rendering function render Vue

Vue through the template to create HTML template. Use render js function can be used to build a DOM.

Because Vue is a virtual DOM, also need to be translated into VNode use template template; and build a DOM with render function, Vue on eliminating the translation process.

When a render function described virtual DOM, Vue provides render a function as a parameter, called the createElement, abbreviated to h.

createElement method has three parameters: The first parameter is a tag name, the second parameter is a property of the object tag, the third parameter is the content of the tag, the third parameter in addition to a string, the array can also pass the VNode.

render function returns a VNode (virtual DOM).

 render:(h) => {
        return h('div',{
           //给div绑定value属性
           props: {
                  value:''
            },
   //给div绑定样式
   style:{
     width:'30px'
   }, 
   //给div绑定点击事件  
           on: {
                 click: () => {
                       console.log('点击事件')
                  }
            },
	})
}    
Published 258 original articles · won praise 21 · views 50000 +

Guess you like

Origin blog.csdn.net/wsln_123456/article/details/105049578