![5de3b6fc07d13a53b7b684a999386b50.png](https://img-blog.csdnimg.cn/img_convert/5de3b6fc07d13a53b7b684a999386b50.png)
前些日子,在整理活动开发的项目时,同事说要不要写一些基础的class,例如某一块内容的居中,然后最后我还是说服了他使用vue插槽去做一个居中组件
这里还有一个话题了:vue项目中css的管理是使用scope还是规范class命名或者CSS Module????可以留言讨论一下,下篇文章讨论一下
这个讨论放在代码后面,下面先来看这个组件
插槽 — Vue.jscn.vuejs.org![e89bbef9c1c407697a838e32ec0f1115.png](https://img-blog.csdnimg.cn/img_convert/e89bbef9c1c407697a838e32ec0f1115.png)
直接上代码
组件:
<template>
<div class="center-box">
<slot name="header"></slot>
<div class="center-box-content">
<slot name="content"></s