37 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Markdown
		
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Markdown
		
	
	
| ## API
 | |
| 
 | |
| 组件提供了一些静态方法,使用方式和参数如下:
 | |
| 
 | |
| - `message.success(content, [duration], onClose)`
 | |
| - `message.error(content, [duration], onClose)`
 | |
| - `message.info(content, [duration], onClose)`
 | |
| - `message.warning(content, [duration], onClose)`
 | |
| - `message.warn(content, [duration], onClose)` // alias of warning
 | |
| - `message.loading(content, [duration], onClose)`
 | |
| 
 | |
| | 参数 | 说明 | 类型 | 默认值 |
 | |
| | --- | --- | --- | --- |
 | |
| | content | 提示内容 | string\|vueNode \|function(h) | - |
 | |
| | duration | 自动关闭的延时,单位秒 | number | 3 |
 | |
| | onClose | 关闭时触发的回调函数 | Function | - |
 | |
| 
 | |
| 还提供了全局配置和全局销毁方法:
 | |
| 
 | |
| - `message.config(options)`
 | |
| - `message.destroy()`
 | |
| 
 | |
| ### message.config
 | |
| 
 | |
| ```js
 | |
| message.config({
 | |
|   top: `100px`,
 | |
|   duration: 2,
 | |
| });
 | |
| ```
 | |
| 
 | |
| | 参数 | 说明 | 类型 | 默认值 |
 | |
| | --- | --- | --- | --- |
 | |
| | duration | 默认自动关闭延时,单位秒 | number | 3 |
 | |
| | getContainer | 配置渲染节点的输出位置 | () => HTMLElement | () => document.body |
 | |
| | top | 消息距离顶部的位置 | string | `24px` |
 |