插槽的两种使用

我们在封装vue组件的使用经常会用到插槽,插槽的使用可以提高组件的复用率,我们在使用具有插槽的组件的时候,要对插槽进行使用,今天发现另外一种使用插槽的方式

  • 定义插槽
<slot name="abc" />
  • 使用插槽
// 1.第一种
<button slot="abc">按钮</button>
// 2.第二种需要使用template模板
<template v-slot:abc>
	<button>按钮<button>
</template>

猜你喜欢

转载自blog.csdn.net/weixin_47979372/article/details/123961351
今日推荐