Vue 插槽slot 以及传递多个props

在这里插入图片描述

<!--
 * @Descripttion: 插槽slot
 * @version: 
 * @Author: zhangfan
 * @email: 2207044692@qq.com
 * @Date: 2020-05-14 09:08:01
 * @LastEditors: zhangfan
 * @LastEditTime: 2020-06-29 09:51:02
--> 
<template>
  <div class="topCon">
    <header-two>
      <template v-slot:header="slotProps">
        <h1>{{slotProps.user1.lastName}}</h1>
        <h1>{{slotProps.user2.lastName}}</h1>
      </template>
      <template v-slot:contenter>
         <p>A paragraph for the main content.</p>
         <p>And another one.</p>
      </template>
      <template v-slot:footer>
         <h2>Here's some contact info</h2>
      </template>
    </header-two>
  </div>
</template>

<script>
import headerTwo from "./headerTwo";
export default {
  name: "enterpriseDetail",
  components: {
    headerTwo
  },
  data() {
    return {
      
    };
  },
  computed: {},
  methods: {
    
  }
};
</script>

<style  scoped lang="less">
</style>

<!--
 * @Descripttion: 
 * @version: 
 * @Author: zhangfan
 * @email: 2207044692@qq.com
 * @Date: 2020-06-28 15:24:08
 * @LastEditors: zhangfan
 * @LastEditTime: 2020-06-29 09:48:01
--> 
<template>
    <div class="headerTwo">
         <slot name="header" v-bind:user1="user1" v-bind:user2="user2">
           <h1>{{user1.firstName}}</h1>
           <h1>{{user2.firstName}}</h1>
         </slot>
         <slot name="contenter"></slot>
         <slot name="footer"></slot>
    </div>
</template>

<script>
export default {
  name: "headerTwo",
  data() {
    return {
      user1:{
          firstName  :"zhang",
          lastName :"san"
      },
      user2:{
          firstName  :"li",
          lastName :"si"
      }
    };
  },
 

};
</script>

<style  scoped lang="less">

</style>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值