render函数的简单使用
<!doctype html>
<html lang="en"> <head>
<meta charset="UTF-8" />
<title>Document</title>
</head> <body>
<div id="app">
<child :level=1>hello Vue</child>
<child :level=6>
<span slot="footer">span</span>
<p slot="header">header slot<span>span</span></p>
</child>
</div>
<script src="node_modules/vue/dist/vue.js"></script>//使用时改为自己的vue路径
<script>
Vue.component('child', {
render: function(createElement) {
return createElement('h'+ this.level, {
'class': {
foo: true,
bar: true
},
style: {
color: "red"
},
attrs: {
id: 'foo',
'data-id': 'bar'
},
domProps: {
//
},
on: {
click: this.clickit
},
},
[this.$slots.default]
)
},
template: '<div v-if="level===1"><slot></slot></div>',
props: {
level: {
type: Number,
required: true
}
},
methods: {
clickit: function() {
console.log('click')
}
}
})
new Vue({
el:"#app"
})
</script>
</body> </html>
render函数的简单使用的更多相关文章
- vue render函数 函数组件化
之前创建的锚点标题组件是比较简单,没有管理或者监听任何传递给他的状态,也没有生命周期方法,它只是一个接受参数的函数 在这个例子中,我们标记组件为functional,这意味它是无状态(没有data), ...
- QTableView另类打印解决方案(复用render函数去解决print问题)
Qt QTableView另类打印解决方案 上回书说道Qt的model/view,我就做了个demo用于显示数据库中的内容.没想到tableview的打印竟然成了问题.我困惑了,难道Qt不应该 ...
- 大白话Vue源码系列(03):生成render函数
阅读目录 优化 AST 生成 render 函数 小结 本来以为 Vue 的编译器模块比较好欺负,结果发现并没有那么简单.每一种语法指令都要考虑到,处理起来相当复杂.上篇已经生成了 AST,本篇依然对 ...
- 大白话Vue源码系列(04):生成render函数
阅读目录 优化 AST 生成 render 函数 小结 本来以为 Vue 的编译器模块比较好欺负,结果发现并没有那么简单.每一种语法指令都要考虑到,处理起来相当复杂.上篇已经生成了 AST,本篇依然对 ...
- Django render函数
render() 此方法的作用---结合一个给定的模板和一个给定的上下文字典,并返回一个渲染后的 HttpResponse 对象. 通俗的讲就是把context的内容, 加载进templates中定义 ...
- Vue学习笔记进阶篇——Render函数
基础 Vue 推荐在绝大多数情况下使用 template 来创建你的 HTML.然而在一些场景中,你真的需要 JavaScript 的完全编程的能力,这就是 render 函数,它比 template ...
- vue render函数
基础 vue推荐在绝大多数情况下使用template来创建你的html.然而在一些场景中,你真的需要javascript的完全编程能力.这就是render函数.它比template更接近编译器 < ...
- render函数和redirect函数的区别+反向解析
render函数和redirect函数的区别+反向解析 1.视图函数:一定是要包含两个对象的(render源码里面有HttpResponse对象) request对象:----->所有的请求 ...
- render函数、createElement函数与vm.$slots
1.render函数.createElement函数 Vue.component('es-header', { render: function (createElement) { return cr ...
随机推荐
- 树形DP+RMQ+尺取法 hdu4123
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4123 参考博客:两种解法-树形dp+二分+单调队列(或RMQ)-hdu-4123-Bob’s Race ...
- pandas数据处理攻略
首先熟悉numpy随机n维数组的生成方法(只列出常用的函数): np.random.random([3, 4]) #生成shape为[3, 4]的随机数组,随机数范围[0.0, 1.0) np.ran ...
- 分布式处理框架MapReduce的深入简出
1).MapReduce的概述 2).MapReduce 编程模型 3).MapReduce架构 4).MapReduce编程 Google MapReduce论文,论文发表于2004年 Hadoop ...
- TOJ 3850: String Function Encoding
传送门:http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3850 时间限制(普通/Java): ...
- 再谈AR中的图像识别算法
之前在<浅谈移动平台创新玩法>简单的猜测了easyar中使用的图像识别算法,基于图片指纹的哈希算法的图片检索 .后再阿里引商大神的指点下,意识到图片检测只适用于静态图片的识别,只能做AR脱 ...
- Alley Bird 跳跳鸟源码
<跳跳鸟Alley Bird>是一款敏捷小游戏.<跳跳鸟Alley Bird>采用了点击屏幕操作玩法,非常简单易上手,同时游戏内容也趣味性十足.<跳跳鸟Alley Bir ...
- cross-env:跨平台设置和使用环境变量
一 项目结构 二 安装依赖 npm install --save-dev cross-env 三 npm脚本 { "name": "demo", "v ...
- Chrome控制台格式化输出
一 格式化输出文字 console.log('%c你好','color:green;'); console.log('%c你好%c啊','color:green;','color:blue;'); 二 ...
- Qt的pro文件--项目配置的部分字段
Qt项目配置的部分字段: 库: LIBS += -L /usr/local/lib -lpcap INCLUDEPATH += /usr/local/include/
- [剑指Offer]9-用两个栈实现队列
题目链接 https://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?tpId=13&tqId=11158&t ...