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参数 有一件事要注意:正如在模板语 ...
随机推荐
- svn 服务器的搭建
SVN服务器运行模式:模式1:svn服务器单独运行 监听: 3690端口 访问: svn://IP模式2: svn 服务器+ apache : 80 端口 访问: http://IP ...
- MVC发送邮件
<> 发送邮件报错说明 发送邮件 假设发送人的邮箱username与邮箱password都没有填写错误:假设报:參数或变量中有语法错误. server响应为:mail from addre ...
- Educational Codeforces Round 12 E. Beautiful Subarrays trie求两异或值大于等于k对数
E. Beautiful Subarrays One day, ZS the Coder wrote down an array of integers a with elements a1, ...
- 0x3A 博弈论之SG函数
博弈即玄学啊 (除了nim和二分图博弈什么都不会 算是学了下SG函数吧 这个东西是针对有向图游戏的,相当于把一个局面看作一个点,到达下个局面相当于建一条边 必胜态SG值为0 那么对于一个点,他的SG值 ...
- Spring《六》管理Bean
BeanWrapper BeanFactory ApplicationContext 1.通常情况下使用BeanFactory.ApplicationContext 2.ApplicationCont ...
- 比较两个时间的大小 举例:CompareDate("12:00","11:15")
//比较两个时间的大小 举例:CompareDate("12:00","11:15") function CompareDate(t1, t2) { var d ...
- css盒模型:BFC、IFC边距重叠解决方案
BFC:块级格式化上下文 IFC:行内格式化上下文 实例如下: <div class="out" style="background: red;"> ...
- HTML5音频可视化频谱跳动代码
今天学习到用canvas来写 HTML5音频可视化频谱跳动代码 将代码在此做一总结: <!DOCTYPE html> <html lang="en"> ...
- Linux内核分析笔记
我在MOOC<Linux内核分析>的学习笔记,这里只做个索引! 计算机是如何工作的
- Sql Server远程还原
1.假设备份文件xxxx.bak大小约300G,还原后所占用的空间为900G 2.磁盘空间只有1T,若将备份文件拷贝过来,空间剩余700G,无法成功还原,因此通过远程方式还原. 例子如下: SQLSE ...