内容管理-vue插槽——默认插槽 & 备用内容 & 具名插槽 & 作用域插槽

内容管理-vue插槽

vue.js-插槽知识文档 网址链接:https://cn.vuejs.org/v2/guide/components-slots.html#ad

  • 当你使用一个组件的时候,想额外插入不同的内容,使用插槽。

  • 默认插槽


<slot>slot>
    • 备用内容

<slot>contentslot>
  • 具名插槽(当你需要往组件内容插入多处内容)

<slot name="content">contentslot>

<div slot="content">con1div>
  • 作用域插槽(当使用组件的时候,获取组件内部的数据,来渲染插槽的内容)
<slot name="content" :abc="msg" def="100">contentslot>

<div slot="content" slot-scope="scope">con1 {{scope.abc}}div>
  • 补充作用域插槽(以上写法是vue2.6.0之前写法,已经淘汰,保留功能)

<template v-slot:content="scope">con1 {{scope.abc}}template>

帮助封装组件,看懂element-ui的组件使用方法。

你可能感兴趣的:(项目-vue-PC端,vue知识,vue)