vue插槽相关
- 在vue3中插槽的写法必须在外面包裹
<child>
<template v-slot="header">
<button>按钮</button>
</template>
</child>
1
2
3
4
5
2
3
4
5
- 在vue2中原来的写法是
<child>
<button slot="header">按钮</button>
</child>
1
2
3
2
3
- 父组件中所有的内容都是在父组件中编译的,子组件中所有的内容都是在子组件中编译的。
<child>
<template v-slot="header">
<button>{{message}}</button>
</template>
</child>
1
2
3
4
5
2
3
4
5
假如父组件中的message是helloworld,子组件中的message是你好,那么在页面显示中,显示的内容是helloworld,因为这个内容是在父组件中编译的
- 默认插槽、具名插槽、作用域插槽
作用域插槽:样式模板由父组件确定,数据由子组件提供
子组件提供给父组件的内容将汇总为一个对象,取值时取对象参数名
编辑 (opens new window)
上次更新: 2024/01/26, 05:03:22
- 01
- python使用生成器读取大文件-500g09-24
- 02
- Windows环境下 Docker Desktop 安装 Nginx04-10
- 03
- 使用nginx部署多个前端项目(三种方式)04-10