# MessageBox

显示提醒框，可以带确认及取消按钮。

## 用法

系统已经将MessageBox插件加入到Vue中了，在组件里面直接调用下面函数即可

* $showMessage(msg, buttons): 显示msg。
* $closeMessage(): 关闭提示框，一般不需要调用

## $showMessage

* buttons：指明要显示的按钮，格式为 ['confirm', 'cancel']，比如只需要显示确认按钮，buttons参数为 ['cancel']。默认为['confirm']，即只显示确认按钮。
* 返回值：$showMessage返回一个Promise，resolve带一个string型返回值，值为'confirm'表示按下了确认按钮，值为'cancel'表示按下了取消按钮。

```
this.$showMessage('提示').then(
  (response) => {
    if (response === 'confirm') {
      console.log('按下了确认按钮')
    } else if (response === 'cancel') {
      console.log('按下了取消按钮')
    }
  }
)
```
如果按下了确认按钮，response为confirm，按下了取消按钮，response为cancel。

## 样式更改

如果对显示的字体有特殊的样式要求，需要将style样式的字符串传入

* this.$showMessage(msg, buttons, titlestyle, msgstyle)
* titlestyle: 标题'提示'的样式
* msgstyle: 显示提示信息msg的样式

```
this.$showMessage('提示信息',['confirm', 'cancel'], '', 'color:red;font-weight:bold')
```
将提示信息的字体加红加粗

## 增加新的提示框用法

如果对整个提示框进行样式重新设计

* this.$showNewMessage(title,msg, buttons, stylename)
* title: 标题内容(默认为'提醒')
* msg: 提示消息正文
* buttons: 提示框按钮选择('确认'、'取消'、'返回')
* stylename: 覆盖样式类

```
this.$showNewMessage('标题','提示信息',['confirm', 'cancel'], '')
```
覆盖样式类:
.newmgs { //覆盖样式类
  .modal-content { 提示框主体
    .modal-header {提示框header部分
      .modal-title { 提示框标题样式
      }
      span {   关闭按钮
      }
    }
    .modal-body { 提示框正文样式
    }
    .modal-footer {  提示框底部样式
      .btn-default {  取消按钮
      }
      .btn-success {  确认按钮
      }
      .btn-cancal {  返回按钮
      }
    }
  }
}
