纷享销客开发者手册 纷享销客开发者手册
  • APL开发手册
  • PWC开发手册
  • OpenAPI 文档
  • 自定义组件(PC端)
  • 自定义组件(小程序)
  • 自定义插件(PC端)
  • 自定义插件(小程序)
  • 第三方集成插件(H5)
  • API(PC端)
  • API(小程序)
  • Fx DevTools
更新日志
  • 简体中文
  • English
  • 自定义组件(PC端)
  • 自定义组件(小程序)
  • 自定义插件(PC端)
  • 自定义插件(小程序)
  • 第三方集成插件(H5)
  • API(PC端)
  • API(小程序)
  • Fx DevTools
更新日志
  • 简体中文
  • English
  • 入门

  • 组件

    • 组件总览
    • UI组件

      • 按钮
      • 单选框
      • 多选框
      • 输入框
      • 计数器
      • 选择器
      • 级联选择器
      • 开关
      • 时间选择器
      • 日期选择器
      • 日期时间选择器
      • 上传
      • 颜色选择器
      • 表格
      • 标签
      • 进度条
      • 树形控件
      • 分页
      • 标记
      • 警告
        • 消息提示
        • 弹框
        • 通知
        • 下拉菜单
        • 步骤条
        • 对话框
        • 卡片
        • 日历
        • 文字提示
        • 弹出框
        • 折叠面板
        • 走马灯
      • 业务组件

    • 示例

    • 常见问题

    目录

    警告

    # FxAlert 警告

    用于页面中展示重要的提示信息。

    # Attributes

    参数 说明 类型 可选值 默认值
    title 标题 string — —
    type 主题 string success/warning/info/error info
    description 辅助性文字。也可通过默认 slot 传入 string — —
    closable 是否可关闭 boolean — true
    center 文字是否居中 boolean — true
    close-text 关闭按钮自定义文本 string — —
    show-icon 是否显示图标 boolean — false
    effect 选择提供的主题 string light/dark light

    # Slot

    Name Description
    — 描述
    title 标题的内容

    # Events

    事件名称 说明 回调参数
    close 关闭alert时触发的事件 —

    # 基本用法

    页面中的非浮层元素,不会自动消失。

    Alert 组件提供四种主题,由type属性指定,默认值为info。

    <template>
      <fx-alert
        title="成功提示的文案"
        type="success">
      </fx-alert>
      <fx-alert
        title="消息提示的文案"
        type="info">
      </fx-alert>
      <fx-alert
        title="警告提示的文案"
        type="warning">
      </fx-alert>
      <fx-alert
        title="错误提示的文案"
        type="error">
      </fx-alert>
    </template>
    
    显示代码 复制代码 复制代码

    # 主题

    Alert 组件提供了两个不同的主题:light和dark。

    通过设置effect属性来改变主题,默认为light。

    <template>
      <fx-alert
        title="成功提示的文案"
        type="success"
        effect="dark">
      </fx-alert>
      <fx-alert
        title="消息提示的文案"
        type="info"
        effect="dark">
      </fx-alert>
      <fx-alert
        title="警告提示的文案"
        type="warning"
        effect="dark">
      </fx-alert>
      <fx-alert
        title="错误提示的文案"
        type="error"
        effect="dark">
      </fx-alert>
    </template>
    
    显示代码 复制代码 复制代码

    # 自定义关闭按钮

    自定义关闭按钮为文字或其他符号。

    在 Alert 组件中,你可以设置是否可关闭,关闭按钮的文本以及关闭时的回调函数。closable属性决定是否可关闭,接受boolean,默认为true。你可以设置close-text属性来代替右侧的关闭图标,注意:close-text必须为文本。设置close事件来设置关闭时的回调。

    <template>
      <fx-alert
        title="不可关闭的 alert"
        type="success"
        :closable="false">
      </fx-alert>
      <fx-alert
        title="自定义 close-text"
        type="info"
        close-text="知道了">
      </fx-alert>
      <fx-alert
        title="设置了回调的 alert"
        type="warning"
        @close="hello">
      </fx-alert>
    </template>
    
    <script>
      export default {
        methods: {
          hello() {
            alert('Hello World!');
          }
        }
      }
    </script>
    
    显示代码 复制代码 复制代码

    # 带有 icon

    表示某种状态时提升可读性。

    通过设置show-icon属性来显示 Alert 的 icon,这能更有效地向用户展示你的显示意图。

    <template>
      <fx-alert
        title="成功提示的文案"
        type="success"
        show-icon>
      </fx-alert>
      <fx-alert
        title="消息提示的文案"
        type="info"
        show-icon>
      </fx-alert>
      <fx-alert
        title="警告提示的文案"
        type="warning"
        show-icon>
      </fx-alert>
      <fx-alert
        title="错误提示的文案"
        type="error"
        show-icon>
      </fx-alert>
    </template>
    
    显示代码 复制代码 复制代码

    # 文字居中

    使用 center 属性让文字水平居中。

    <template>
      <fx-alert
        title="成功提示的文案"
        type="success"
        center
        show-icon>
      </fx-alert>
      <fx-alert
        title="消息提示的文案"
        type="info"
        center
        show-icon>
      </fx-alert>
      <fx-alert
        title="警告提示的文案"
        type="warning"
        center
        show-icon>
      </fx-alert>
      <fx-alert
        title="错误提示的文案"
        type="error"
        center
        show-icon>
      </fx-alert>
    </template>
    
    显示代码 复制代码 复制代码

    # 带有辅助性文字介绍

    包含标题和内容,解释更详细的警告。

    除了必填的title属性外,你可以设置description属性来帮助你更好地介绍,我们称之为辅助性文字。辅助性文字只能存放单行文本,会自动换行显示。

    <template>
      <fx-alert
        title="带辅助性文字介绍"
        type="success"
        description="这是一句绕口令:黑灰化肥会挥发发灰黑化肥挥发;灰黑化肥会挥发发黑灰化肥发挥。 黑灰化肥会挥发发灰黑化肥黑灰挥发化为灰……">
      </fx-alert>
    </template>
    
    显示代码 复制代码 复制代码

    # 带有 icon 和辅助性文字介绍

    最后,这是一个同时具有 icon 和辅助性文字的样例。

    <template>
      <fx-alert
        title="成功提示的文案"
        type="success"
        description="文字说明文字说明文字说明文字说明文字说明文字说明"
        show-icon>
      </fx-alert>
      <fx-alert
        title="消息提示的文案"
        type="info"
        description="文字说明文字说明文字说明文字说明文字说明文字说明"
        show-icon>
      </fx-alert>
      <fx-alert
        title="警告提示的文案"
        type="warning"
        description="文字说明文字说明文字说明文字说明文字说明文字说明"
        show-icon>
      </fx-alert>
      <fx-alert
        title="错误提示的文案"
        type="error"
        description="文字说明文字说明文字说明文字说明文字说明文字说明"
        show-icon>
      </fx-alert>
    </template>
    
    显示代码 复制代码 复制代码
    标记
    消息提示

    ← 标记 消息提示→

    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式