vue 2.0 scopedSlots和slots在render函数中的应用示例
渲染内容为:
hello from functional render scopedSlots
render scopedSlots
named slot of render
hello from functional render scopedSlots
functional render scopedSlots
named slot of functional render
源码:
<!DOCTYPE html>
<html lang='zh'>
<head>
<title></title>
</head>
<body>
<div id="app">
<rrr>
<p slot="static"> named slot of render</p>
<template slot="scp" scope="props">
<p>hello from functional render scopedSlots</p>
<p>{{ props.text }}</p>
</template>
</rrr>
<hr>
<fff>
<p slot="static"> named slot of functional render</p>
<template slot="scp" scope="props">
<p>hello from functional render scopedSlots</p>
<p>{{ props.text }}</p>
</template>
</fff>
</div>
<script src="https://cdn.staticfile.org/vue/2.3.2/vue.js"></script>
<script>
Vue.component('rrr', {
render: function (h) {
var children = this.$scopedSlots.scp({text:"render scopedSlots"})
children = children.concat(this.$slots.static)
return h('div',children)
},
})
Vue.component('fff', {
functional: true,
render: function (h, ctx) {
var children = ctx.data.scopedSlots.scp({text:"functional render scopedSlots"})
children = children.concat(ctx.slots().static)
return h('div',children)
},
})
var app = new Vue({
}).$mount('#app')
</script>
</body>
</html>
vue 2.0 scopedSlots和slots在render函数中的应用示例的更多相关文章
- vue入门:(底层渲染实现render函数、实例生命周期)
vue实例渲染的底层实现 vue实例生命周期 一.vue实例渲染的底层实现 1.1实例挂载 在vue中实例挂载有两种方法:第一种在实例化vue时以el属性实现,第二种是通过vue.$mount()方法 ...
- 使用React.Fragment替代render函数中div的包裹
1.在 React 中,render 函数中 return 的内容只能有一个根节点,如果多个元素嵌套,需要用一个标签元素包裹 这个包裹的标签通常用 div,示例如下: class App extend ...
- 【转】【Html】Vuejs2.0学习之二(Render函数,createElement,vm.$slots,函数化组件,模板编译,JSX)
1.Render函数 所以直接来到Render,本来也想跳过,发现后面的路由貌似跟它还有点关联.先来看看Render 1.1 官网一开始就看的挺懵的,不知道讲的是啥,动手试了一下,一开头讲的是Rend ...
- Vuejs2.0学习之二(Render函数,createElement,vm.$slots,函数化组件,模板编译,JSX)
时隔一周多,因为一些别的事情绊住了,下面接着写.中间这段时间也有看官方文档,发现正如他所说90%的基础内容都一样,所以这里直接跳到我比较关注的东东上,要是想看看哪些不一样,可以参考这个http://v ...
- 大白话Vue源码系列(03):生成render函数
阅读目录 优化 AST 生成 render 函数 小结 本来以为 Vue 的编译器模块比较好欺负,结果发现并没有那么简单.每一种语法指令都要考虑到,处理起来相当复杂.上篇已经生成了 AST,本篇依然对 ...
- 大白话Vue源码系列(04):生成render函数
阅读目录 优化 AST 生成 render 函数 小结 本来以为 Vue 的编译器模块比较好欺负,结果发现并没有那么简单.每一种语法指令都要考虑到,处理起来相当复杂.上篇已经生成了 AST,本篇依然对 ...
- element-ui(vue版)使用switch时change回调函数中的形参传值问题
需求说明 有多个switch组件 需要知道switch的状态 表格中当前行(scope.row)的数据 问题描述 官方文档中对switch中change的描述: 目前能得到switch的状态值,但是无 ...
- vue render函数
基础 vue推荐在绝大多数情况下使用template来创建你的html.然而在一些场景中,你真的需要javascript的完全编程能力.这就是render函数.它比template更接近编译器 < ...
- Vue.2.0.5-Render 函数
基础 Vue 推荐使用在绝大多数情况下使用 template 来创建你的 HTML.然而在一些场景中,你真的需要 JavaScript 的完全编程的能力,这就是 render 函数,它比 templa ...
随机推荐
- jquery的attr()方法
一.定义和用法 attr() 方法设置或返回被选元素的属性和值. 当该方法用于返回属性值,则返回第一个匹配元素的值. 当该方法用于设置属性值,则为匹配元素设置一个或多个属性/值对. 二.语法 返回属性 ...
- Ajax实现注册无刷新验证用户名是否存在
1. [代码][JavaScript]代码 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ...
- jacascript AJAX 学习
前言:这是笔者学习之后自己的理解与整理.如果有错误或者疑问的地方,请大家指正,我会持续更新! AJAX 是 asynchronous javascript and XML 的简写,就是异步的 java ...
- ACE工具概述
一:ACE简介 ADAPTIVE 通信环境(ACE,ADAPTIVE Communication Enviroment)是一种广泛的主机基础设施中间件,ACE可以免费获得,可以在http://ace. ...
- java====color、font、button、label、textfield、textarea使用
1. Color类 µ 公共静态属性:共13个静态属性,分别代表13种不同的颜色常量. µ 构造函数 ü public Color(int r,int g,int b):以整数形式给出红.绿.蓝三个分 ...
- further occurrences of HTTP header parsing errors will be logged at DEBUG level.错误
今天进行项目测试的时候出现了further occurrences of HTTP header parsing errors will be logged at DEBUG level.错误,查了半 ...
- Asp.net Core2.0 缓存 MemoryCache 和 Redis
自从使用Asp.net Core2.0 以来,不停摸索,查阅资料,这方面的资料是真的少,因此,在前人的基础上,摸索出了Asp.net Core2.0 缓存 MemoryCache 和 Redis的用法 ...
- SpringMVC入门到精通(一)
推荐一个很不错的学习博客 http://jinnianshilongnian.iteye.com/blog/1752171
- 【网络流】【BZOJ1070】【SCOI2007】修车
原题链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1070 题意:问你如何分配老司机使得每部车的等待时间之和最短. 解题思路:本题不易正做,考虑 ...
- UVA 1451 Average
A DNA sequence consists of four letters, A, C, G, and T. The GC-ratio of a DNA sequence is the numbe ...