使用scopedSlots來顯示作用域插槽,通過下面的代碼: <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> 但是在瀏覽器中沒有任何顯示,請問如何正確使用才能夠顯示出text的值呢?
vue的scopedSlots用法,如何顯示作用域插槽?
紅糖糍粑
2019-03-14 18:15:14