指尖上的记忆指尖上的记忆
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub

vue3的slot调用的两种方式 先定义一个组件 UserCenter:

<template>
  <div class="user-center-wrapper">
    <!--  slot -->
        <slot name="user_wrapper"></slot>
  </div>
</template>

调用这个组件:

<template>
   <div >
     //other code ...
  </div>
  <UserCenter>
      <!--  调用方式1 -->
  	  <template #user_wrapper>
		  <div class="img-box">
		      <img class="person abs-center" src="~/assets/img/profile-person.svg" alt="">
		  </div>
	</template>
  </UserCenter>
</template>  
<template>
   <div >
     //other code ...
  </div>
  <UserCenter>
      <!--  调用方式2 -->
  	  <template v-slot:user_wrapper>
		  <div class="img-box">
		      <img class="person abs-center" src="~/assets/img/profile-person.svg" alt="">
		  </div>
	</template>
  </UserCenter>
</template>