我是靠谱客的博主 寂寞滑板,最近开发中收集的这篇文章主要介绍vue插槽的使用,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

子组件slot:

Son.vue

<template>
  <div>
    <slot>默认显示内容</slot>
    <slot name="nameSlot">具名插槽的用法</slot>
  </div>
</template>

父组件调用:

v-slot 的别名是#

<template>
    <son-slot>
      <template v-slot:nameSlot> My Image’s Title </template>
      <h2>ccc</h2>
      <h2>sss</h2>
    </son-slot>
</template>
<script>
import sonSlot from '@/components/Son.vue'
export default {
  components: {
    sonSlot
  }
}
</script>

参考链接

原文链接: vue插槽的使用

最后

以上就是寂寞滑板为你收集整理的vue插槽的使用的全部内容,希望文章能够帮你解决vue插槽的使用所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(46)

评论列表共有 0 条评论

立即
投稿
返回
顶部