[new feature] add Notify component (#2135)

This commit is contained in:
neverland
2018-11-25 10:36:07 +08:00
committed by GitHub
parent 00458839a2
commit eb44209a5a
22 changed files with 465 additions and 5 deletions
+56
View File
@@ -0,0 +1,56 @@
## Notify 消息提示
### 使用指南
``` javascript
import { Notify } from 'vant';
Vue.use(Notify);
```
### 代码演示
#### 基础用法
```js
Notify('通知内容');
```
#### 自定义配置
```js
Notify({
message: '通知内容',
duration: 1000,
background: '#1989fa'
});
```
#### 组件内调用
引入 Notify 组件后,会自动在 Vue 的 prototype 上挂载 $notify 方法,便于在组件内调用。
```js
export default {
mounted() {
this.$notify('提示文案');
}
}
```
### 方法
| 方法名 | 参数 | 返回值 | 介绍 |
|------|------|------|------|
| Notify | `options | message` | notify 实例 | 展示提示 |
| Notify.clear | - | `void` | 关闭提示 |
| Notify.setDefaultOptions | `options` | `void` | 修改默认配置,对所有 Notify 生效 |
| Notify.resetDefaultOptions | - | `void` | 重置默认配置,对所有 Notify 生效 |
### Options
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|------|------|------|------|------|
| message | 展示文案 | `String` | - | 1.4.6 |
| duration | 展示时长(ms),值为 0 时,notify 不会消失 | `Number` | `3000` | 1.4.6 |
| color | 字体颜色 | `String` | `#fff` | 1.4.6 |
| background | 背景颜色 | `String` | `#f44` | 1.4.6 |