Skip to content

气泡确认框 Popconfirm

点击元素,弹出气泡式的确认框。

基本用法

气泡确认框的基本用法。


代码事例
vue
<template>
  <fk-popconfirm title="Are you sure you want to delete?">
    <fk-button>Click To Delete</fk-button>
  </fk-popconfirm>
</template>

底部带边框 Border

气泡确认框的带边框。


代码事例
vue
<template>
  <fk-popconfirm title="Are you sure you want to delete?" :border="true" content="内容内容内容内容内容内容内容内容内容">
    <fk-button>Click To Delete</fk-button>
  </fk-popconfirm>
</template>

气泡确认框的footer自定义。


代码事例
vue
<template>
  <fk-space>
    <fk-popconfirm :border="true" size="small" title="Are you sure you want to delete?" footer-align="left" content="内容内容内容内容内容内容内容内容内容">
        <fk-button>Footer Left</fk-button>
    </fk-popconfirm>
    <fk-popconfirm :border="true" size="small" footer-align="center" content="内容内容内容内容内容内容内容内容内容">
        <fk-button>Footer Center</fk-button>
    </fk-popconfirm>
    <fk-popconfirm :border="true" size="small" footer-align="right" content="内容内容内容内容内容内容内容内容内容">
        <fk-button>Footer Right</fk-button>
    </fk-popconfirm>
  </fk-space>
</template>

自定义按钮

自定义按钮的文字或图标。


代码事例
vue
<template>
  <fk-popconfirm title="Do you want to discard the draft?" ok-text="Discard" cancel-text="No">
    <fk-button>Discard</fk-button>
  </fk-popconfirm>
</template>

弹出位置

popconfirm 支持 12 个不同的方位。分别为:上左 上右 下左 下右 左上 左下 右上 右下


代码事例
vue
<template>
  <div :style="{position: 'relative', width: '440px', height: '280px'}">
    <fk-popconfirm title="This is a Popconfirm" position="tl">
      <fk-button class="button" :style="{position: 'absolute',top:'0',left:'70px'}">TL</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="top">
      <fk-button class="button" :style="{position: 'absolute',top:'0',left:'180px'}">TOP</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="tr">
      <fk-button class="button" :style="{position: 'absolute',top:'0',left:'290px'}">TR</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="bl">
      <fk-button class="button" :style="{position: 'absolute',top:'240px',left:'70px'}">BL</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="bottom">
      <fk-button class="button" :style="{position: 'absolute',top:'240px',left:'180px'}">BOTTOM</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="br">
      <fk-button class="button" :style="{position: 'absolute',top:'240px',left:'290px'}">BR</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="lt">
      <fk-button class="button" :style="{position: 'absolute',top:'60px',left:'10px'}">LT</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="left">
      <fk-button class="button" :style="{position: 'absolute',top:'120px',left:'10px'}">LEFT</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="lb">
      <fk-button class="button" :style="{position: 'absolute',top:'180px',left:'10px'}">LB</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="rt">
      <fk-button class="button" :style="{position: 'absolute',top:'60px',left:'350px'}">RT</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="right">
      <fk-button class="button" :style="{position: 'absolute',top:'120px',left:'350px'}">RIGHT</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="This is a Popconfirm" position="rb">
      <fk-button class="button" :style="{position: 'absolute',top:'180px',left:'350px'}">RB</fk-button>
    </fk-popconfirm>
  </div>
</template>

<style scoped lang="less">
.button{
  width: 100px;
}
</style>

确认框类型

通过 type 属性可以设置确认框类型。


代码事例
vue
<template>
  <fk-space>
    <fk-popconfirm title="Are you sure you want to delete?" type="info">
      <fk-button>Click To Delete</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="Are you sure you want to delete?" type="success">
      <fk-button>Click To Delete</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="Are you sure you want to delete?" type="warning">
      <fk-button>Click To Delete</fk-button>
    </fk-popconfirm>
    <fk-popconfirm title="Are you sure you want to delete?" type="error">
      <fk-button>Click To Delete</fk-button>
    </fk-popconfirm>
  </fk-space>
</template>

<popconfirm> 组件继承 <trigger> 组件的全部属性

API

<popconfirm> Props

参数名描述类型默认值
title标题string-
content内容string-
position弹出位置'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br' | 'left' | 'lt' | 'lb' | 'right' | 'rt' | 'rb''top'
popup-visible (v-model)气泡确认框是否可见boolean-
default-popup-visible气泡确认框默认是否可见(非受控模式)booleanfalse
type气泡确认框的类型'info' | 'success' | 'warning' | 'error''info'
ok-text确认按钮的内容string-
cancel-text取消按钮的内容string-
ok-loading确认按钮是否为加载中状态booleanfalse
ok-button-props确认按钮的PropsButtonProps-
cancel-button-props取消按钮的PropsButtonProps-
content-class弹出框内容的类名ClassName-
content-style弹出框内容的样式CSSProperties-
arrow-class弹出框箭头的类名ClassName-
arrow-style弹出框箭头的样式CSSProperties-
popup-container弹出框的挂载点string | HTMLElement-
on-before-ok触发 ok 事件前的回调函数。如果返回 false 则不会触发后续事件,也可使用 done 进行异步关闭。(done: (closed: boolean) => void) => void | boolean | Promise<void | boolean>-
on-before-cancel触发 cancel 事件前的回调函数。如果返回 false 则不会触发后续事件。() => boolean-

<popconfirm> Events

事件名描述参数
popup-visible-change气泡确认框的显隐状态改变时触发visible: boolean
ok点击确认按钮时触发-
cancel点击取消按钮时触发-

<popconfirm> Slots

插槽名描述参数
icon图标-
title标题-
content内容-

基于 MIT 许可发布