message_tips_chen
v1.1.0
Published
messageTips
Readme
参数 object || string
参数为object类型时
属性 | 类型 | 默认值 | 是否必填 | 说明 ---|---|---|---|--- mask | boolean | true | 否 | 控制背景层 showClose | boolean | false | 否 | 控制是否显示关闭按钮 title | string | | 否 | 标题 content | string 或 number | | 是 | 主题文案 confirmText | string | 确定 | 否 | 确定按钮文案 showCancel | boolean | false | 否 | 是否显示取消按钮 cancelText | string | 取消 | 否 | 取消按钮文案
参数为string类型时,即为content属性
复制组件引用
复制components/message文件加 main.js内引入 import '@/components/message';
npm包引用
<!--安装-->
yarn add message_tips_chen --save
<!--main.js内引用-->
import { $messageTips, $alert, $confirm } from 'message_tips_chen';
Vue.prototype.$messageTips = $messageTips;
Vue.prototype.$alert = $alert;
Vue.prototype.$confirm = $confirm;应用举例
<!-- 参数为string类型 -->
const res = await this.$messageTips('消息文案').catch(e => e);
if (res === 'confirm') {
console.log('click Confirm');
} else if (res === 'cancel') {
console.log('click Cancel');
}
<!-- 参数为object类型 -->
const res = await this.$messageTips({
mask: true,
showClose: false,
title: '',
confirmText: '确定',
cancelText: '取消',
content: '消息文案',
showCancel: false,
}).catch(e => e);
// 类型为confrim或者是cancel
if (res === 'confirm') {
console.log('click Confirm');
} else if (res === 'cancel') {
console.log('click Cancel');
}其他命令调用
- this.$alert 等同于将showCancel设为false,参数类型和主体一致
- this.$comfirm 等同于将showCancel设为true,参数类型和主体一致
