在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ vue的scopedSlots用法,如何顯示作用域插槽?

vue的scopedSlots用法,如何顯示作用域插槽?

使用scopedSlots來(lái)顯示作用域插槽,通過(guò)下面的代碼:

               <div id="K7">
                    <u-component>
                    <template slot-scope="props">
                    <p>作用域插槽2</p>
                     
                    </template>
                    </u-component>
               </div>
               <script>
               Vue.component('u-component',{
               render: function (createElement) {
              return createElement('div', [
                 createElement('child', {
                      scopedSlots: {
                   default: function (props) {
                      return createElement('span', props.text)
                       }
                        }
                  })
                ])
                  },
                  data:function(){
                  return {text:"nvjs"}
                }
               })
                   new Vue({
                    el:'#K7'
                   })
               </script>
               
           

但是在瀏覽器中沒(méi)有任何顯示,請(qǐng)問(wèn)如何正確使用才能夠顯示出text的值呢?

回答
編輯回答
陌如玉

render(h){

  return  h('div',{},this.$scopedSlots.default({text:this.text})])  

}

2018年1月12日 22:04
編輯回答
萢萢糖

樓主,你解決這個(gè)問(wèn)題沒(méi)有

2017年12月18日 21:33