# Notify 消息通知
### 介绍
在页面顶部展示消息提示
### 安装
``` javascript
import { createApp } from 'vue';
import { Notify } from '@nutui/nutui-taro';
const app = createApp();
app.use(Notify);
```
## 使用示例
``` html
基础用法
主要通知
成功通知
危险通知
警告通知
自定义背景色和字体颜色
自定义时长5s
```
``` javascript
import { reactive } from 'vue';
export default {
setup() {
const onClosed = () => console.log('closed');
const onClick = () => console.log('click');
const baseState = {
state: reactive({
show: false,
desc: '基础用法'
}),
methods: {
cellClick() {
baseState.state.show = true;
}
}
};
const notifyState = {
state: reactive({
show: false,
desc: '',
type: 'primary'
}),
methods: {
cellClick(type: string, desc: string) {
notifyState.state.show = true;
notifyState.state.type = type;
notifyState.state.desc = desc;
}
}
};
const customState = {
state: reactive({
show: false,
desc: '',
type: 'primary',
duration: 3000
}),
methods: {
cellClick(type: string, desc: string, duration: number) {
customState.state.show = true;
customState.state.type = type;
customState.state.desc = desc;
customState.state.duration = duration;
}
}
};
return {
baseState,
notifyState,
customState,
onClosed,
onClick
};
}
};
```
### Props
| 字段 | 说明 | 类型 | 默认值 |
|------------|-------------------------------------------------------|---------|----------|
| type | 提示的信息类型(primary,success ,danger,warning) | String | 'danger' |
| message | 展示文案,支持通过\n换行 | Boolean | false |
| duration | 展示时长(ms),值为 0 时,notify 不会消失 | String | 3000 |
| color | 字体颜色 | String | 空 |
| background | 背景颜色 | String | 空 |
| class-name | 自定义类名 | String | |
### Events
| 事件名 | 说明 | 回调参数 |
|--------|--------------|----------|
| click | 点击事件回调 | 无 |
| closed | 关闭事件回调 | 无 |