vue中具名插槽slot使用详细教程版

 1 普通的插槽  父组件引入子组件home2

<template>
  <div style="margin: 50px; line-height: 34px; width: 800px">
    <h2></h2>
    <h3>slot是Vue中的插槽,首先它是使用在 子组件 中的</h3>
    <h2>1 . 普通 slot 插槽</h2>
    <h3>在子组件内占坑,在父组件里填坑,这句话说的特别好</h3>
    <h3>
      slot一般都是子组件定义了主体部分,父组件引入,然后父组件根据需求不同需要向里面添加不同的内容
    </h3>

    <h3></h3>
    <h2>2 . 具名插槽</h2>
    <h3>具名插槽的使用语法</h3>
    <h3>1 . 子组件定义slot时,在标签上加上name='xxx'属性</h3>
    <h3>2 . 父组件将想插入的部分最外部的div上加上slot="xxx"属性</h3>
    <h3>子组件里面的slot标签不能少,不然父组件里面写的出不来出不来</h3>
    <home2 @click.native="clickSave(1)">自定义按钮 </home2>
    <home2 @click.native

猜你喜欢

转载自blog.csdn.net/jieweiwujie/article/details/126750159