Vue学习------组件插槽

Vue学习------组件插槽

首先在子组件里定义 slot标签

<slot name="one"><a>1111</a></slot>
<slot name="two" ><a>2222</a></slot>

之后在父组件里用v-solt:one标明使用插槽

<template v-slot:one>
          <button>55555</button>
</template>

如果插槽传过来值

<slot name="two" :user="user"><a>2222</a></slot>

父组件需使用two=”data“来获取值 这也是子组件传值给父组件的一种

<template v-slot:two="data">
          <button>{{data.user.name}}</button>
</template>

子组件里的插槽也可以使用 default缺省值

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值