Dialog
弹出式提示框,有多种交互形式。Demo
引入
import { Dialog } from 'vue-pmui';
Vue.use(Dialog);
例子
alert
this.$alert('message');
confirm
this.$confirm('success')
.then(() => {
// confirm
})
.catch(() => {
// cancel
});
prompt
this.$prompt('success')
.then((inputValue) => {
// confirm
console.log(inputValue);
})
.catch(() => {
// cancel
});
自定义
this.$dialog({
title: '我是标题',
content: '我是内容',
showInput: true,
inputPlaceholder: '输入些什么吧',
confirm: (val) => {
console.log(val ? `点击了确认,输入了${val}` : 'confirm');
},
cancel: () => console.log('点击了取消')
});
作为组件使用
<!-- button -->
<pm-button @click="show"> 唤起dialog </pm-button>
<!-- dialog -->
<pm-dialog ref="dialog"
:showClose="false">
<template slot="header">
<h1>Header Slot</h1>
</template>
<template>
<h2>Default Slot</h2>
</template>
<template slot="footer">
<div style="width: 100%;text-align: center">
<h3>Footer Slot</h3>
<a @click="hide">Click me to hide</a>
</div>
</template>
</pm-dialog>
export default {
methods: {
show() {
this.$refs.dialog.show();
},
hide() {
this.$refs.dialog.hide();
}
}
};
Props
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
title | 提示框标题 | String | 提示 | |
content | 提示框内容 | String | ||
showClose | 是否显示右上角关闭按钮 | Boolean | fasle | |
showMask | 是否显示遮罩层 | Boolean | true | |
closeOnClickMask | 是否点击遮罩层关闭 | Boolean | true | |
closeOnConfirm | 是否确认时关闭对话框 | Boolean | true | |
closeOnClickMask | 是否点击遮罩层关闭 | Boolean | true | |
showConfirmButton | 是否显示确认按钮 | Boolean | true | |
confirmButtonText | 确认按钮文本 | String | 确定 | |
showCancelButton | 是否显示取消按钮 | Boolean | false | |
cancelButtonText | 取消按钮文本 | String | 取消 | |
showInput | 是否显示输入框 | Boolean | false | |
inputType | 输入框类型 | String | text/tel/number/email/password/date/datetime | text |
inputPlaceholder | 输入框占位符 | String |
Slots
Name | 描述 |
---|---|
default | 提示框主体 |
header | 提示框头部 |
footer | 提示框脚部 |