zoukankan      html  css  js  c++  java
  • 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>
    
  • 相关阅读:
    linux查看端口
    linux下Git代码
    linux安装mysql
    pip工具更新及解决"No module named pip"问题
    demo-bootstrap实现滑动开关
    vue 随笔
    css 解决盒子移动鼠标丢失产生的抖动问题
    笔记-纯css实现select的placeholder
    笔记-移动端rem适配和解决安卓手机键盘唤起引起样式问题
    demo-tab切换
  • 原文地址:https://www.cnblogs.com/xiangnan/p/6909721.html
Copyright © 2011-2022 走看看