Skip to content

Preview 表单预览

介绍

表单预览组件通常用于展示表单数据,执行操作等等。

导入

js
import Preview from '@/components/display/Preview.vue'

用法

基础用法

使用 Preview 组件展示表单数据,支持文本和图片类型的值。

vue
<template>
  <Preview 
    title="订单金额"
    desc="订单号 XX00000324234988"
    extra="¥88.80"
    :extraProps="{
      color: 'danger',
      fontSize: 40,
    }"
    :items="[{
      title: '物流单号',
      value: '21321654009562600343',
    },
    {
      title: '创建时间',
      value: '2025-12-20 09:20',
    },
    {
      title: '付款时间',
      value: '2025-12-20 09:30',
    },
    {
      title: '发货前照片',
      value: 'https://imengyu.top/assets/images/test/2.jpg',
      valueType: 'image',
    },
    {
      title: '包裹照片',
      value: [
        'https://imengyu.top/assets/images/test/2.jpg',
        'https://imengyu.top/assets/images/test/3.jpg',
      ],
      valueType: 'image',
    },
    {
      title: '订单备注',
      value: '客户要求安全配送至收获地址,送达后需要及时联系,当面签收。请快递员注意配送,谢谢!',
    }]"
  />
</template>

展示操作按钮

在表单预览组件底部添加操作按钮。

vue
<template>
  <Preview 
    title="订单金额"
    desc="订单号 XX00000324234988"
    extra="¥88.80"
    :extraProps="{
      color: 'danger',
      fontSize: 40,
    }"
    :items="[
      {
        title: '物流单号',
        value: '21321654009562600343',
      },
      {
        title: '创建时间',
        value: '2025-12-20 09:20',
      },
      {
        title: '过期时间',
        value: '2025-12-20 09:30',
      }
    ]"
    :actions="[
      {
        text: '查看商品',
        color: 'primary',
      },
      {
        text: '取消订单',
        color: 'danger',
      }
    ]"
  />
</template>

API 参考

Preview

表单预览组件。

Props

名称说明类型必填默认值
title大标题string-
desc副标题string-
extra大标题右侧额外信息string-
extraProps大标题右侧额外信息文字属性TextProps{}
backgroundColor卡片背景颜色string'white'
items项目列表{ title: string, value: string | string[], valueType?: 'text' | 'image' }[]-
actions操作按钮列表{ text: string, color?: string, props?: ButtonProp, onClick?: (item) => void }[]-
titleProps项目标题文字属性TextProps{}
titleWidth项目标题宽度string | number300
titleColor项目标题文字颜色string'text.second'
valueProps项目值文字属性TextProps{}
valueColor项目值文字颜色string'text.content'

Slots

名称说明
title标题区域
items项目区域
actions操作区域

主题变量

名称类型默认值说明
PreviewBackgroundColorstring'white'卡片背景颜色
PreviewExtraTextPropsobject{}大标题右侧额外信息文字属性
PreviewTitleColorstring'text.second'项目标题文字颜色
PreviewValueColorstring'text.content'项目值文字颜色
PreviewItemTitleWidthnumber300项目标题宽度
PreviewItemTitleTextPropsobject{}项目标题文字属性
PreviewItemValueTextPropsobject{}项目值文字属性
PreviewPaddingnumber30内边距
PreviewItemVerticalPaddingnumber10项目垂直内边距
PreviewItemGapnumber20项目间距