Skip to content

PopConfirm 问答泡

演示

使用方式:
popConfirm的使用可以用传统插槽方式和虚拟元素触发
<template>
  <div class="row">
    <cl-pop-confirm
      @cancel="cancel"
      @confirm="confirm"
      title="确定删除订单?"
      content="此操作不可撤回,数据将不会保存。"
    >
      <template #reference>
        <cl-button>普通用法</cl-button>
      </template>
    </cl-pop-confirm>
    <cl-pop-confirm
      :openDelay="1000"
      :virtualRef="buttonRef"
      title="确定删除订单?"
      content="此操作不可撤回,数据将不会保存。"
    >
    </cl-pop-confirm>
    <cl-button ref="buttonRef">virtualRef用法</cl-button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const buttonRef = ref<HTMLElement | null>(null)
function cancel() {
  console.log('cancel')
}
function confirm() {
  console.log('confirm')
}
</script>

<style lang="scss" scoped>
@import '../popup/popup-demo.scss';
</style>
自定义内容:
传入content插槽,自定义内容,title:自定义标题
<template>
  <div class="row">
    <cl-pop-confirm hideIcon hideConfirm hideCancel>
      <template #reference>
        <cl-button>普通用法</cl-button>
      </template>
      <template #content>
        <table>
          <tr>
            <td>缸号</td>
            <td>卷数</td>
            <td>数量</td>
          </tr>
          <tr>
            <td>11</td>
            <td>10</td>
            <td>100</td>
          </tr>
          <tr>
            <td>12</td>
            <td>10</td>
            <td>100</td>
          </tr>
        </table>
      </template>
      <template #title>
        <div>明细</div>
      </template>
    </cl-pop-confirm>
    <cl-pop-confirm :virtualRef="buttonRef" hideIcon hideConfirm hideCancel>
      <template #reference>
        <cl-button>80</cl-button>
      </template>
      <template #content>
        <table>
          <tr>
            <td>缸号</td>
            <td>卷数</td>
            <td>数量</td>
          </tr>
          <tr>
            <td>11</td>
            <td>10</td>
            <td>100</td>
          </tr>
          <tr>
            <td>12</td>
            <td>10</td>
            <td>100</td>
          </tr>
        </table>
      </template>
      <template #title>
        <div>明细</div>
      </template>
    </cl-pop-confirm>
    <cl-button ref="buttonRef">virtualRef用法</cl-button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const buttonRef = ref<HTMLElement | null>(null)
</script>

<style lang="scss" scoped>
@import '../popup/popup-demo.scss';
table {
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}
tr {
  border-top: 1px solid #dfe2e5;
}

tr:nth-child(2n) {
  background-color: #f6f8fa;
}

td,
th {
  border: 1px solid #dfe2e5;
  padding: 0.6em 1em;
}
</style>

popConfirm 参数描述

参数描述类型可选值默认值
title标题string--
content内容string--
confirmText确定按钮文案String--
cancelText取消按钮文案String--
icon自定义 iconString-cl-icon-warning
iconColor自定义 icon 颜色String-#FE352D
hideIcon隐藏 iconBoolean-false
hideClose隐藏关闭按钮Boolean-false
hideConfirm隐藏确定按钮Boolean-false
hideCancel隐藏取消按钮Boolean-false

如下参数:参考 popup

参数描述类型可选值默认值
v-model / modelValue默认状态是否可见Boolean-false
disabledpop 是否可用Boolean-false
trigger触发方式Stringclick hover manualclick
placement出现位置String-top-center
preRender是否需要预渲染Boolean-false
enterable鼠标是否可进入到泡中Boolean-true
popupClass自定义 pop 样式String--
offset泡偏移量(px)Number-0
visibleArrow是否显示箭头Boolean-true
arrowOffset箭头偏移Number-0
openDelay延迟出现(hover 触发)Number-100 ms
closeDelay延迟隐藏(hover 触发)Number-100 ms
virtualRef虚拟触发的元素ComponentPublicInstance<HTMLElement>|<HTMLElement>--
outsideAutoCloseWithManual手动触发模式下,是否点击内容外自动关闭boolean-false

popConfirm 插槽

参数描述
title标题
content内容
footer操作区
reference触发 popConfirm 显示的 元素

popConfirm 事件

事件名称描述回调参数
confirm点击确认按钮时触发-
cancel点击取消按钮时触发-