将子组件引入父组件中,在引入的子组件标签对中,写入信息,子组件可以通过slot标签对去展示父组件的内容,如果父组件中标签对没写东西,子组件中slot标签对写了,会暂时使用slot标签对的内容
如果子组件中的slot是具名插槽,在父组件中可以用任意标签对
<Tmplate slot="slot名字">xxxxsssssddd<Tmplate> xxxxsssssddd就会展示到子组件的具名卡槽中
插槽显不显示、怎样显示是由父组件来控制的,而插槽在哪里显示就由子组件来进行控制
![](https://img.haomeiwen.com/i27493437/e57ac6717e240f35.png)
![](https://img.haomeiwen.com/i27493437/3850e575b11cf85d.png)
![](https://img.haomeiwen.com/i27493437/62134618f3fcfb83.png)
![](https://img.haomeiwen.com/i27493437/2ef92fc38cf1f595.png)
![](https://img.haomeiwen.com/i27493437/ace69b23cbc2a6f0.png)
![](https://img.haomeiwen.com/i27493437/8b8890a00b20f321.png)
没有对应值的其他内容会被放到子组件中没有添加name属性的slot中
![](https://img.haomeiwen.com/i27493437/066427fd2bd9c194.png)
![](https://img.haomeiwen.com/i27493437/ffcb76fa0b5ccfb0.png)
![](https://img.haomeiwen.com/i27493437/8d37b46894fa0e7a.png)
![](https://img.haomeiwen.com/i27493437/9ebbe1ef50960b70.png)
template
![](https://img.haomeiwen.com/i27493437/4bf842bed5cf90f5.png)
![](https://img.haomeiwen.com/i27493437/cdc506962126b74e.png)
网友评论