Confirm
Install

Install

建议参照例子使用 v-transfer-dom 将弹窗插入 body 节点下,避免组件非 body 子节点导致的各种问题。

该组件支持以plugin形式调用:

以插件形式调用时,和template中使用不同,属性名请使用小驼峰式,比如confirmText而不是confirm-text

import  { ConfirmPlugin } from 'vux'
Vue.use(ConfirmPlugin)
// 显示
const _this = this // 需要注意 onCancel 和 onConfirm 的 this 指向
this.$vux.confirm.show({
  // 组件除show外的属性
  onCancel () {
    console.log(this) // 非当前 vm
    console.log(_this) // 当前 vm
  },
  onConfirm () {}
})

// 隐藏
this.$vux.confirm.hide()

// prompt形式调用
this.$vux.confirm.prompt('placeholder', {
  onCancel () {}
  onConfirm () {}
})

// 设置输入值
this.$vux.confirm.setInputValue('value') // 注意需要在 onShow 事件中执行

// 获取显示状态
this.$vux.confirm.isVisible() // v2.9.1 支持

API

Props

nametypedefaultdescriptionrequired version
valuebooleanfalsevisibility of the component--
show-inputbooleanfalsewhether show input or not. If true, slot will not workv2.5.0
placeholderstringplaceholder of prompt, valid when show-input is truev2.5.0
themestringiosdialog's style, can be ios or android--
hide-on-blurbooleanfalseif closing dialog when clicking on mask--
titlestringdialog title--
contentstringdialog content, can use html. Invalid when using slot--
confirm-textstring确认(confirm)text of confirm button--
cancel-textstring取消(cancel)text of cancel button--
mask-transitionstringvux-fademask's transition--
dialog-transitionstringvux-dialogdialog's transition--
close-on-confirmbooleantruewhether close automatically when confirm button is clickedv2.5.0
input-attrsobjectinput attributesv2.5.7
mask-z-indexnumber
string
1000zIndex of maskv2.6.4
show-cancel-buttonbooleantrueif show cancel buttonv2.9.2
show-confirm-buttonbooleantrueif show confirm buttonv2.9.2

Events

nameparamsdescriptionrequired version
@on-cancel--triggers when the cancel button is clicked--
@on-confirm(value)triggers when the confirm button is clicked--
@on-show--triggers when the dialog shows--
@on-hide--triggers when the dialog hides--

Slots

namedescriptionrequired version
defaultbody content of the dialog--

Functions

nameparamsdescriptionrequired version
setInputValue(value)set input value when show-input is truev2.5.5


Contributors

Contributors

Total commits quantity: 50,Total contributors quantity: 8

airylandunclayzhangzicaoSapphireKwanQiongrong JiangFisher光君

Changelog

Releases

  • v2.9.2 [feature] Support prop: showCancelButton showConfirmButton #2795
  • v2.9.1 [feature] add isVisible function for ConfirmPlugin #2704
  • v2.9.0 [fix] fix inputAttrs issue with no-default-value #2618
  • v2.9.0 [fix] fix focus auto-blur issue #2610
  • v2.8.0 [fix] fix hard to move cursor
  • v2.7.3 [fix] fix hard to get focus on input(thanks to @Sapphire2k)
  • v2.6.5 [enhance] fix click events trigger twice when clicking fast #2048
  • v2.6.4 [feature] support prop:mask-z-index
  • v2.5.8 [feature] Support method:setInputValue for plugin #1846
  • v2.5.7 [feature] Support prop:input-attrs #1799
  • v2.5.5 [feature] Add method:setInputValue #1746
  • v2.5.0 [feature] Support prop:close-on-confirm
  • v2.5.0 [feature] Support prop:show-input
  • v2.1.1-rc.11 [fix] Fix plugin value and event watchers
  • v2.1.1-rc.11 [fix] Reset prop data when used as plugin