Files
mes-ui-d2/docs/zh/components/container.md
liyang 1e3fdc9294 文档
Former-commit-id: 59deacc8b9e4922059112e6c570dff3aabe8dbde [formerly 60bf37418278254d92ccea71dd2cd37372c47349] [formerly 59deacc8b9e4922059112e6c570dff3aabe8dbde [formerly 60bf37418278254d92ccea71dd2cd37372c47349] [formerly 59deacc8b9e4922059112e6c570dff3aabe8dbde [formerly 60bf37418278254d92ccea71dd2cd37372c47349] [formerly 60bf37418278254d92ccea71dd2cd37372c47349 [formerly 27311c339ff22e9cf89fd7bfdb7e630bb5eaa35d [formerly 5c096dbd7ce0729d9ef65ff96b3355f2d97990e4]]]]]
Former-commit-id: 08a91ad3070bca2e9f43324466cbe01b3d9b687d
Former-commit-id: c3b2bc6e88a3f8e81ca18a9b7659e0b5703c32a9
Former-commit-id: c6e5ccca326d10738c56de5ce65ae9a5d9536ed7 [formerly e4f276ec812afd3ee382e62237bfc8f8fa290856]
Former-commit-id: 161939d7bc01bb12586d6972ad60222a01b95420
Former-commit-id: fbddc91a66278c09c9888dabd684f10385996839
Former-commit-id: e0a98bdf8677a8f00ef346f22c3e0e222620b994
Former-commit-id: 836e1b6a04c4f71fbaa59128f81b2f4e6cf1fa6b
Former-commit-id: 386447c79311ad5c43d5a7b4002888a0107a9ae6
2018-07-18 08:48:46 +08:00

2.5 KiB

页面容器

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

参数

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

使用方法

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

::: tip 注意 为了统一效果,<template> 的直接子组件必须是 <d2-container> :::

<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>

自适应填充页面容器

无论内容高度多少,都会自动撑满页面,并有可选的 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="card">
  主体内容
</d2-container>

使用 slot

卡片型容器只有 header 插槽

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

隐形页面容器

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

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

使用 slot

隐形页面容器只有 header 插槽

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

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