插槽(slot)用法

(具名插槽)

示例:

子组件:

<template>
  <div>
<!--    <slot name="tipsMessage"></slot>-->
    <div class="fixed-bottom shadow w100 box flex-row items-center content-between fit-app bg-fff" style="z-index:10">
      <slot name="leftBtn"></slot>
      <slot name="rightBtn"></slot>
    </div>
    <p class="h170"></p>
  </div>
</template>

<script>
export default {

}
</script>

<style lang="less" scoped>
.h170{
    height: 170px;
}
.fixed-bottom{
    border-radius: 44px 44px 0px 0px;
    padding: 40px 40px;
    .br-2A2B2B{
        border: 2px solid #2A2B2B;
    }
}
.fit-app {
  padding-bottom: calc(44px + constant(safe-area-inset-bottom));
  padding-bottom: calc(44px + env(safe-area-inset-bottom));
}
</style>

父组件:

 1.引入组件

 2.可以用任意容器标签,只要标签内加上 slot="子组件的对应位置的名字"即可显示在对应位置上

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值