vue Render scopedSlots
render 中 slot 的一般默认使用方式如下:
this.$slots.default 对用 template的<slot>的使用没有name 。
想使用多个slot 的话。需要对slot命名唯一。使用this.$slots.name 在render中添加多个slot。
- <body>
- <div class="" id="app">
- <myslot>
- <div>this is slot</div>
- </myslot>
- </div>
- <script>
- Vue.component('myslot',{
- render:function(createElement){
- var he=createElement('div',{domProps:{innerHTML:'this child div'}});
- return createElement('div',[he,this.$slots.default])
- }
- });
- var app=new Vue({
- el:'#app'
- })
- </script>
- </body>
多个slot的使用
- <body>
- <div class="" id="app">
- <myslot>
- <div slot="name1">this is slot</div>
- <div slot="name2">The position is slot2 </div>
- </myslot>
- </div>
- <script>
- Vue.component('myslot',{
- render:function(createElement){
- var he=createElement('div',{domProps:{innerHTML:'this child div'}});
- return createElement('div',[he,this.$slots.name2,this.$slots.name1])
- }
- });
- var app=new Vue({
- el:'#app'
- })
- </script>
- </body>
在vue2.1.0新添加了scope(虽然感觉有点怪,但是用习惯了,还蛮好用的)
同样给出一般使用和多个使用示例,
- <body>
- <div class="" id="app">
- <myslot>
- <template scope="props">
- <div>{{props.text}}</div>
- </template>
- </myslot>
- </div>
- <script>
- Vue.component('myslot',{
- render:function(createElement){
- var he=createElement('div',{domProps:{innerHTML:'this child div'}});
- return createElement('div',[he,this.$scopedSlots.default({
- text:'hello scope'
- })])
- }
- });
- var app=new Vue({
- el:'#app'
- })
- </script>
- </body>
多个$scopedSlot的使用
- <body>
- <div class="" id="app">
- <myslot>
- <template slot="name2" scope="props">
- <div>{{props.text}}</div>
- </template>
- <template slot="name1" scope="props">
- <span>{{props.text}}</span>
- </template>
- </myslot>
- </div>
- <script>
- Vue.component('myslot',{
- render:function(createElement){
- var he=createElement('div',{domProps:{innerHTML:'this child div'}});
- return createElement('div',
- [he,
- this.$scopedSlots.name1({
- text:'hello scope'
- }),
- this.$scopedSlots.name2({
- text:'$scopedSlots using'
- })])
- }
- });
- var app=new Vue({
- el:'#app'
- })
- </script>
- </body>
vue Render scopedSlots的更多相关文章
- vue render function
vue render function https://vuejs.org/v2/guide/render-function.html { // Same API as `v-bind:class`, ...
- vue render 渲染函数
vue render 渲染函数 经常看到使用render渲染函数的示例,而且在一些特殊情况下,确实更好使用,可以更加有效地细分组件,因而借助vue-element-admin来学习一波 render函 ...
- vue render里面的nativeOn
vue render里面的nativeOn的解释官方的解释是:// 仅对于组件,用于监听原生事件,而不是组件内部使用 `vm.$emit` 触发的事件. 官方的解释比较抽象 个人理解: 父组件要在子组 ...
- vue render function & dataset
vue render function & dataset https://vuejs.org/v2/guide/render-function.html#The-Data-Object-In ...
- vue render & array of components & vue for & vue-jsx
vue render & array of components & vue for & vue-jsx https://www.cnblogs.com/xgqfrms/p/1 ...
- vue render html string
vue render html string shit element ui render string array relativeShowConvert(data) { // log(`data` ...
- vue render函数
基础 vue推荐在绝大多数情况下使用template来创建你的html.然而在一些场景中,你真的需要javascript的完全编程能力.这就是render函数.它比template更接近编译器 < ...
- vue render & JSX
vue在绝大多数使用template是没问题的,但在某些场合下,使用render更适合. 一.render函数 1.createElement 参数 createElement 可接受三个参数 1){ ...
- vue render {} 对象 说明文档
Vue学习笔记进阶篇——Render函数 http://www.mamicode.com/info-detail-1906336.html 深入data object参数 有一件事要注意:正如在模板语 ...
随机推荐
- Debian以下的ntp服务(ntpdate)的安装
/********************************************************************* * Author : Samson * Date ...
- 2015.04.24,外语,读书笔记-《Word Power Made Easy》 12 “如何奉承朋友” SESSION 34
1.no fatigue indefatigable([indi'fætigәb(ә)l] adj. 不知疲倦的)来自faigue,in-是反义词缀:后缀-able表示able to be,因此ind ...
- Ubuntu输入su提示认证失败的解决方法
用su切换,输入密码提示认证失败,这下搞了吧,后来一经查阅原来Ubuntu安装后,root用户默认是被锁定了的,不允许登录,也不允许 su 到 root ,对于桌面用户来说这个可能是为了增强安全性,但 ...
- 使用Chrome插件Postman进行简单的Get/Post测试
转自:https://blog.csdn.net/dearmorning/article/details/56854236 Postman插件: 一种网页调试与发送网页http请求的chrome插件, ...
- Comparable与Comparator区别(实现和使用)
一.Comparable接口 1.Comparable接口是什么? 此接口强行对实现它的每个类的对象进行整体排序.此排序被称为该类的自然排序 ,类的 compareTo 方法被称为它的自然比较方法 . ...
- BZOJ 4710 容斥原理+dp
//By SiriusRen #include <cstdio> using namespace std; int n,m,a[1005]; typedef long long ll; l ...
- php-fpm配置笔记
php-fpm配置不当,导致服务器经常出现502错误,上个学期多次调整都没有解决,网上找来资料,大都是增加max_children,可是我都加到顶了,php-fpm log里面还是有大量的警告: ee ...
- [转]C#事件-使用事件需要的步骤
事件是C#中另一高级概念,使用方法和委托相关.奥运会参加百米的田径运动员听到枪声,比赛立即进行.其中枪声是事件,而运动员比赛就是这个事件发生后的动作.不参加该项比赛的人对枪声没有反应. 从程序员的角度 ...
- redis的key对应mysql数据表设计
根据用户名来查询用户信息 在关系型数据中,除主键外,还有可能其他列也步骤查询, 如上表中, username 也是极频繁查询的,往往这种列也是加了索引的. 转换到k-v数据中,则也要相应的生成一条按照 ...
- Windows 10 的功能更新,版本 1809 - 错误 0x80070002
一般是双硬盘导致的问题,请打开电脑拆掉系统盘以外的硬盘,一般为固态硬盘和物理硬盘同时使用的电脑会出现此错误.