Skip to content

XPanel 面板

示例

基本用法

面板标题
Body

<template>
  <div>
    <XPanel header="面板标题" size="large" shadow="hover"> Body</XPanel>
  </div>
</template>

<script lang="ts" setup>
  import { XPanel } from '@vtj/ui';
</script>

<style lang="scss" scoped>
  .x-panel {
    margin: 10px 0;
  }
</style>

定义尺寸

面板主要标题副标题内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
面板标题
Body
面板标题
Body

<template>
  <div>
    <XPanel
      card
      :header="header"
      shadow="always"
      width="600px"
      height="200px"
      :body="{ padding: false }"
      :footer="{ padding: false }">
      <div v-for="n in 20">{{ n }}</div>
      <template #actions>
        <XAction :icon="VtjIconPlus" mode="icon" background="hover"></XAction>
        <XAction
          :icon="VtjIconSetting"
          mode="icon"
          background="hover"></XAction>
      </template>
    </XPanel>

    <XPanel card header="面板标题" size="large" shadow="hover">
      Body

      <template #actions>
        <XAction :icon="VtjIconPlus" mode="icon"></XAction>
        <XAction :icon="VtjIconSetting" mode="icon"></XAction>
      </template>
    </XPanel>

    <XPanel card header="面板标题" size="small">
      Body

      <template #actions>
        <XAction :icon="VtjIconPlus" mode="icon" size="small"></XAction>
        <XAction :icon="VtjIconSetting" mode="icon" size="small"></XAction>
      </template>
    </XPanel>
  </div>
</template>

<script lang="ts" setup>
  import { XPanel, XAction } from '@vtj/ui';

  import { VtjIconPlus, VtjIconSetting } from '@vtj/icons';

  const header = {
    content: '面板主要标题',
    subtitle: '副标题内容',
    more: true,
    icon: {
      icon: VtjIconSetting,
      color: 'var(--el-color-primary)'
    },
    onClick() {
      console.log('header clicked!');
    }
  };
</script>

<style lang="scss" scoped>
  .x-panel {
    margin: 10px 0;
  }
</style>

定义 header

面板主要标题副标题内容
添加
设置
Body
面板标题

<template>
  <div>
    <XPanel :header="header" shadow="always">
      Body
      <template #actions>
        <XAction :icon="VtjIconPlus" mode="text" label="添加"></XAction>
        <XAction :icon="VtjIconSetting" mode="text" label="设置"></XAction>
      </template>
    </XPanel>

    <XPanel header="面板标题" size="small">
      <ElTabs>
        <ElTabPane label="选项卡一"></ElTabPane>
        <ElTabPane label="选项卡二"></ElTabPane>
      </ElTabs>
    </XPanel>
  </div>
</template>

<script lang="ts" setup>
  import { XPanel, XAction } from '@vtj/ui';

  import { VtjIconPlus, VtjIconSetting } from '@vtj/icons';

  import { ElTabs, ElTabPane } from 'element-plus';

  const header = {
    content: '面板主要标题',
    subtitle: '副标题内容',
    more: true,
    icon: {
      icon: VtjIconSetting,
      color: 'var(--el-color-primary)'
    },
    onClick() {
      console.log('header clicked!');
    }
  };
</script>

<style lang="scss" scoped>
  .x-panel {
    margin: 10px 0;
  }
</style>

API

属性

属性名说明类型默认值
fit宽高自适应booleanfalse
height指定高度,fit 为true 失效string | number-
width指定宽度,fit 为true 失效string | number-
border显示边框booleantrue
radius圆角booleantrue
card卡片模式boolean-
size尺寸string-
shadow阴影设置string < 'none' | 'always' | 'hover'>-
header头部设置string | object-
bodybody设置object-
footer尾部设置object-

暴露

名称说明类型
bodyRefbody实例-

Released under the MIT License.