Vue.component( 'btn' , { |
template: ` |
<button> |
<slot></slot> |
<slot></slot> |
</button> |
` |
}) // 什么是slot例子 |
Vue.component( 'child' , { |
template: ` |
<div> |
<h2>标题一</h2> |
<slot name= "slot1" ></slot> |
<h2>标题二</h2> |
<slot name= "slot2" ></slot> |
</div> |
` |
}) // 如果有多个slot如何分配实例 |
new Vue({ |
el: '#app' , |
data: { |
} |
}) |