mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-11-06 13:32:08 +08:00
Notify
Install
import { Notify } from 'vant';
Vue.use(Notify);
Usage
Basic Usage
Notify('Notify Message');
Custom Config
Notify({
message: 'Notify Message',
duration: 1000,
background: '#1989fa'
});
$notify Method
After import the Notify component, the $notify method is automatically mounted on Vue.prototype, making it easy to call within a vue component.
export default {
mounted() {
this.$notify('Notify Message');
}
}
API
Methods
| Methods | Attribute | Return value | Description |
|---|---|---|---|
| Notify | `options | message` | notify instance |
| Notify.clear | - | void |
Close notify |
| Notify.setDefaultOptions | options |
void |
Set default options of all notifies |
| Notify.resetDefaultOptions | - | void |
Reset default options of all notifies |
Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| message | Message | string |
- |
| duration | Duration(ms), won't disappear if value is 0 | number |
3000 |
| color | Message color | string |
#fff |
| background | Background color | string |
#f44 |
| className | Custom className | any |
- |
| onClick | Callback function after click | Function |
- |
| onOpened | Callback function after opened | Function |
- |
| onClose | Callback function after close | Function |
- |