首先我们传统的对于DOM的操作基本上都是通过js直接的获取一个节点,然后对DOM进行增加或者是删除。而Vue的Render这个函数是通过js虚拟的添加dom节点,然后虚拟的添加到html节点上去。

算了感念的东西不知道是怎么回事,大概意思就是 用Render函数的话比正常我们通过传统方式要节省时间和消耗就可以了。下面介绍用法。本人也不明白怎么回事,反正性能方面要比传统的方式要好,如果想要详细的查看的话,自己去百度vue的官方的文档。

Render最经典的就是createElement方法。下面介绍。

createElement 构成了Vue Virtual Dom的魔板,它有三个参数:

createElement (
// {String | Object | Function}
// 一个 HTMl标签,转件选项,或者一个函数
// 必须return 上述中最少一个
'div',
// {Object}
// 一个对应属性的数据对象,可选
// 您可以在template中使用
{
// 稍后详细的介绍
},
// {String | Array}
// 子节点(vnodes),可选
[
createElement('h1','hello world'),
createElement(MyComponent,{
props:{
someProp : 'foo'
}
}),
'bar'
]
)

下面粘贴一个我的事例

props:{
level:{
type:Number,
required:true
},
title:{
type:String,
default:'url传参'
}
},
render:function(createElement) {
return createElement(
'h' + this.level,
[
createElement(
'a',
{
domProps:{
href: '#' + this.title
}
},
this.$slots.default
)
]
)
}

效果为:

这里用到了一个组件,url-render这个组件,这是自定义的组件,不要想多了。

关于Vue的Render的讲解的更多相关文章

  1. html select options & vue h render

    html select options & vue h render https://developer.mozilla.org/en-US/docs/Web/HTML/Element/opt ...

  2. vue h render function & render select with options bug

    vue h render function & render select with options bug https://github.com/xgqfrms/vue/issues/41 ...

  3. vue iview render里面 没有双向绑定 renderHeader 要序列化 反序列 一下

    vue iview render里面 没有双向绑定 renderHeader 要序列化 反序列 一下 renderHeader: (h, params) => { return [ h('Rad ...

  4. 终于搞懂了vue 的 render 函数(一) -_-|||

    终于搞懂了vue 的 render 函数(一) -_-|||:https://blog.csdn.net/sansan_7957/article/details/83014838 render: h ...

  5. vue之render基本书写方法

    Vue 推荐在绝大多数情况下使用 template 来创建你的 HTML.然而在一些场景中,你真的需要 JavaScript 的完全编程的能力,这就是 render 函数,它比 template 更接 ...

  6. vue使用render渲染&jsx

    vue&jsx文档 vue实例属性 // App.ts import hBtn from './components/hBtn' import hUl from './components/h ...

  7. 012——VUE中todos示例讲解class中应用表达式

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. Vue中render: h => h(App)的含义

    // ES5 (function (h) { return h(App); }); // ES6 h => h(App); 官方文档 render: function (createElemen ...

  9. vue之Render函数

    (1)什么是Render函数 先来看一个场景,在博客网中,一般有一级标题.二级标题.三级标题...,为了方便分享url,它们都做成了锚点,点击后,会将内容加载网址后面,以#分隔. 例如‘特性’是一个& ...

随机推荐

  1. 禁止IOS双击上滑

    var agent = navigator.userAgent.toLowerCase(); var iLastTouch = null; if (agent.indexOf("iphone ...

  2. 修改mysql编码方式

    第一种:     通过mysql命令行修改: 1)首先查看数据库字符编码,命令为: show variables like’collation_%’; show variables like’char ...

  3. c#利用三层架构做一个简单的登录窗体

    就个人而言,三层架构有点难理解,不知道该如何下手,各层与各层之间怎么调用 最近一直在研究三层架构,经过网上学习与多方打听写一下自己的心得.有不足之处,可以评论和私聊探讨 言归正传: 三层架构(3-ti ...

  4. May 09th 2017 Week 19th Tuesday

    Everything you see exists together in a delicate balance. 世上所有的生命都在微妙的平衡中生存. A delicate balance? Can ...

  5. March 6 2017 Week 10 Monday

    A well-spent day brings happy sleep. 丰盈白日,安眠晚间. Recently my sleep is not so good, for one thing I go ...

  6. ABAP和Java里关于DEFAULT(默认)机制的一些语言特性

    ABAP 740的新语法: 上图的代码相当于: DATA: ls_data LIKE LINE OF it_data. READ TABLE it_data INTO ls_data WITH KEY ...

  7. 利用CRM中间件Middleware从ERP下载Customer Material的常见错误

    使用事务码VD51和VD52创建和修改Customer Material. 下图是我在ERP创建的Material,为其维护了一个Customer Material AOP. 当下载到CRM后,在We ...

  8. Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired,

    Did not receive a reply. Possible causes include: the remote application did not send a reply, the m ...

  9. ACM-ICPC(9/25)

    DP专题 记忆化搜索与递推(方式) DAG模型 记忆化搜索: 用d[状态] 的特殊值表示是否计算过. 用vis[状态]是否访问过 DAG模型: 矩形嵌套:d(i) 以 i 结点开始的最长长度,​ 存在 ...

  10. hack-checkbox

    checkbox选择按钮要用我们自己的样式,看到这个的时候,很可能会以为需要checkbox才能实现,用css可能很难.其实狠简单. <style> .checkbox input{ di ...