Vue中的render函数随笔
使用vue-cli创建项目后,再main.js里面有这样一段代码:
new Vue({
render:h => h(App)
}).$mount('#app')
render函数是渲染一个视图,然后给el挂载,如果没有render那页面什么也不会显示
最原始的:
render:function(createElement){
return createElement(App)
}
缩写: (这里的h就是createElement的缩写)
render (createElement) {
return createElement(App)
}
再缩写:
render (h) {
return h()App)
}
使用ES6箭头函数
render: h => h(APP)
例子:
return h(this.tag, {
class,
style
}, this.$slots.default
)
第一个this.tag表示标签名,比如div
第二个参数是定义创建的组件的一些属性,比如class、style
第三个参数 this.$slots.default 父组件调用子组件时,传递的slot都保持在$slots.default这个数组里面
Vue中的render函数随笔的更多相关文章
- vue中的render函数介绍
简介:对于不了解slot的用法(参考:大白话vue-slot的用法)又刚接触render函数的同学来说,官网的解释无疑一脸懵逼,这里就整理下个人对render函数的理解 问题: 1.render函数是 ...
- 在vue中结合render函数渲染指定的组件到容器中
1.demo 项目结构: index.html <!DOCTYPE html> <html> <head> <title>标题</title> ...
- 理解Vue中的Render渲染函数
理解Vue中的Render渲染函数 VUE一般使用template来创建HTML,然后在有的时候,我们需要使用javascript来创建html,这时候我们需要使用render函数.比如如下我想要实现 ...
- iview table中的render函数使用
1.表格列数据内容过多可以用以下两个属性解决: ellipsis:"true', tooltip:true 使每个列的内容如果过多的话变为省略号 2.table中的render函数(实现根据 ...
- Vue.js之render函数基础
刚才翻了一下博客,才发现,距离自己写的第一篇Vue的博客vue.js之绑定class和style(2016-10-30)已经过去一年零两天.这一年里,自己从船厂的普通技术员,成为了一个微型不靠谱创业公 ...
- 关于Vue中的 render: h => h(App) 具体是什么含义?
render: h => h(App) 是下面内容的缩写: render: function (createElement) { return createElement(App); } 进一步 ...
- vue中的钩子函数
什么是vue的钩子函数? Vue 实例在被创建时,会经过一系列的初始化过程,初始化过程中会运行一些函数,叫做生命周期钩子函数,通过运用钩子函数,用户在可以在Vue实例初始化的不同阶段添加自己的代码,以 ...
- Vue2.x中的Render函数
Render函数是Vue2.x版本新增的一个函数:使用虚拟dom来渲染节点提升性能,因为它是基于JavaScript计算.通过使用createElement(h)来创建dom节点.createElem ...
- 【转】vue中的钩子函数。。
前言 在vue开发SPA应用的过程中,多数情况下我们需要解决一个问题 就是在路由跳转的过程中需要更新你SPA应用的 title , 这一节不说其他,就展示如何使用 vue-router 的 导航钩子 ...
随机推荐
- 使用phpexcel上传下载excel文件
1. 下载 <?php /** * Created by lonm.shi. * Date: 2012-02-09 * Time: 下午4:54 * To change this templat ...
- tarjan强连通算法
#include <iostream> #include <string.h> using namespace std; ; ; struct edge{ int v,next ...
- 词根 sent/sens
sense--> to feel (来自于拉丁语 sensus) 词根sent/sens 表示感知 sentiment 感情 consent consensus con- 一起, 一起的感 ...
- 关于MySQL数据库——增删改查语句集锦
一.基本的sql语句 CRUD操作:create 创建(添加)read 读取update 修改delete 删除 1.添加数据insert into Info values('p009','张三',1 ...
- 第28月第23天 lineFragmentPadding
1.lineFragmentPadding https://blog.csdn.net/lwb102063/article/details/78748186
- 第27月第17天 objc_msgSendSuper
1.objc_msgSendSuper super 的含义,消息转发会调用 objc_msgSendSuper, 就是 去父类的方法列表中找到 initWithFrame:这个方法,然后调用,调用的主 ...
- 第24月第30天 scrapy《TensorFlow机器学习项目实战》项目记录
1.Scrapy https://www.imooc.com/learn/1017 https://github.com/pythonsite/spider/tree/master/jobboleSp ...
- jmeter(五)几种不同的content-type方式
今天我们来讲3种常见的content-type方式,及jmeter应用时信息头和传参方式的不同: 参照博客http://www.cnblogs.com/imyalost/p/6726795.html ...
- GDI+学习---1.初识GDI+
---恢复内容开始--- GDI+: GDI+由一组C++类实现,是对于GDI的继承,GDI+不仅优化了大部分GDI性能而且提供了更多特性.允许应用程序开发者将信息显示在显示器或者打印机上,而无需考虑 ...
- A - Piece of Cake Kattis - pieceofcake (数学)
题目链接: A - Piece of Cake Kattis - pieceofcake 题目大意:给你一个多边形,然后给你这个多边形的每个点的坐标,让你从这个n个点中选出k个点,问这个k个点形成的面 ...