Files
mes-ui-d2/docs/zh/components/container.md
liyang 76437df5a2 完善
Former-commit-id: 2633b0171ec3b6e6d96949cf593dea3c461abf11 [formerly 2633b0171ec3b6e6d96949cf593dea3c461abf11 [formerly 2633b0171ec3b6e6d96949cf593dea3c461abf11 [formerly 2633b0171ec3b6e6d96949cf593dea3c461abf11 [formerly 2d44dc9f335eb0079ddc5b3f5f619c36989748ad [formerly a583e1e6fba053d60a995188b644efa464d9bf1e]]]]]
Former-commit-id: a240818780d5876f318a89c1a09e3e682772e9ed
Former-commit-id: 28a7f169d87181f709d32ec8707a7ebe5ac9df51
Former-commit-id: 96be7e6c54ddfb42d711bb4a8f13c629b597d47e [formerly 77bd5abfee56adf12ae864fbbc7f4c5221e1518b]
Former-commit-id: 06ac51608fe59c768fec2500c3a2b172cc5d7868
Former-commit-id: 63f9816eaa1580fb3984be356af09ea60378a4d0
Former-commit-id: 7ba4c0097008bc9ce444f88cb2403a00d745a9fc
Former-commit-id: bc04fb37f399a32fee891282f12b2ed4cb2b6fc1
Former-commit-id: 0f7ea2d17f4845bdc3436e76e848bf0705bf2a25
2018-07-15 10:08:53 +08:00

2.3 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 来启用自定义滚动条,看起来更美观一些

有些情况下使用滚动优化模式会有意外影响,例如页面内含有可拖拽的元素,这时候最好不要使用此模式

示例:

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

隐形页面容器

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

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

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