Files
mes-ui-d2/docs/zh/components/container.md
liyang 4c567a126f no message
Former-commit-id: 5736b537b80522974d00a7086d4acfc8a0d83d6f [formerly 5736b537b80522974d00a7086d4acfc8a0d83d6f [formerly 5736b537b80522974d00a7086d4acfc8a0d83d6f [formerly 5736b537b80522974d00a7086d4acfc8a0d83d6f [formerly d5a50f370faea7529cfe5c8e81df9d9b383da219 [formerly d2511cd85dd9f4641cb06715fc7e697b6de496a2]]]]]
Former-commit-id: e5da464e7ed7892cd3b874f350cbfd95f80a66c4
Former-commit-id: c23f670851d81787f70c3da8e1efd36c218a5d2c
Former-commit-id: c92cd8fda84ab8a6cf89e6c1eafe828dac2c96e3 [formerly 277bb06065ff0371dd6e8ab11a13ed0d9a82a93a]
Former-commit-id: c48ead6d4c5214286cf545ca93f98eccc91da427
Former-commit-id: fdedbcfc8a0f4f1fdd62e6965e057a3b502842fc
Former-commit-id: fc8ebc6a3a504a4e88d7da2c509f2096daafdc56
Former-commit-id: 51e87cc6d508caabd90f8520a56235a7f881a85c
Former-commit-id: e1f06ac6b5d54f353ce329d02599e3bd8b973b90
2018-07-03 12:36:22 +08:00

1.9 KiB

页面容器

页面容器组件是每个页面的基础,为了在整个项目中统一效果,它应该是 <template> 组件的直接子组件

参数

参数名 介绍 必选 值类型 可选值 默认值
type 容器类型 String card ghost full card
scroll 滚动优化 Boolean false
responsive 响应式宽度 Boolean false

::: tip responsive 参数设置只在 type 等于 cardghost 时生效 :::

使用方法

一个基础单文件页面组件的示例

<template>
  <d2-container>
    <template slot="header">
      可选的 header 内容 ...
    </template>
    主体内容 ...
  </d2-container>
</template>

<script>
export default {
  name: 'your-component-name'
}
</script>

<style lang="scss">
// 需要的话引入
@import '~@/assets/style/public.scss';
</style>

基础页面容器

高度根据内容适应

<d2-container>
  主体内容
</d2-container>

使用 slot

<d2-container>
  <template slot="header">我是插入到 header 中的内容</template>
  主体内容
</d2-container>

自适应填充页面容器

无论内容高度多少,都会自动撑满页面,并有可选的 headerfooter 插槽

示例:

<template>
  <d2-container type="full">
    <template slot="header">
      可选的 header 内容 ...
    </template>
    主体内容 ...
    <template slot="footer">
      可选的 footer 内容 ...
    </template>
  </d2-container>
</template>

v1.1.4 新增

你可以通过设置 scroll 来启用自定义滚动条,看起来更美观一些

隐形页面容器

不显示任何背景色和边框,通常这个模式只有在极少情况下会使用

<d2-container type="ghost">
  主体内容
</d2-container>

如果你不希望内容紧贴上边,可以在内容外层容器设置 class="d2-mt"