问题描述

在使用element ui中的el-row的gutter属性时,组件无法实现间隔,在设置了gutter属性后,依然维持原样,而控制台不报错

如图
在这里插入图片描述
对应的错误代码

<template>
  <div>
    <h3>layout组件的使用</h3>
    <!--创建页面中的一行-->
    <el-row :gutter="20">
      <el-col :span="6" class="col">占用6份</el-col>
      <el-col :span="6" class="col">占用6份</el-col>
      <el-col :span="6" class="col">占用6份</el-col>
      <el-col :span="6" class="col">占用6份</el-col>
    </el-row>
    <el-row :gutter="50">
      <el-col :span="4" class="col">占用4份</el-col>
      <el-col :span="8" class="col">占用8份</el-col>
      <el-col :span="3" class="col">占用3份</el-col>
      <el-col :span="9" class="col">占用9份</el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "Layout"
}
</script>

<style scoped>
  .col{
    border: 1px solid red;
  }
</style>

问题解决

需要在子组件中添加div标签能实现正常间隔

<template>
  <div>
    <h3>layout组件的使用</h3>
    <!--创建页面中的一行-->
    <el-row :gutter="20">
      <el-col :span="6"><div class="col">占用6份</div></el-col>
      <el-col :span="6"><div class="col">占用6份</div></el-col>
      <el-col :span="6"><div class="col">占用6份</div></el-col>
      <el-col :span="6"><div class="col">占用6份</div></el-col>
    </el-row>
    <el-row :gutter="50">
      <el-col :span="4"><div class="col">占用4份</div></el-col>
      <el-col :span="8"><div class="col">占用8份</div></el-col>
      <el-col :span="3"><div class="col">占用3份</div></el-col>
      <el-col :span="9"><div class="col">占用9份</div></el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "Layout"
}
</script>

<style scoped>
  .col{
    border: 1px solid red;
  }
</style>

在这里插入图片描述

GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:2 个月前 )
c345bb45 6 个月前
a07f3a59 * Update transition.md * Update table.md * Update transition.md * Update table.md * Update transition.md * Update table.md * Update table.md * Update transition.md * Update popover.md 7 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐