feat: notification add onClick
							parent
							
								
									8933cc524e
								
							
						
					
					
						commit
						0d49773553
					
				|  | @ -82,4 +82,12 @@ describe('notification', () => { | |||
|     }) | ||||
|     done() | ||||
|   }) | ||||
| 
 | ||||
|   it('trigger onClick', () => { | ||||
|     notification.open({ | ||||
|       message: 'Notification Title', | ||||
|       duration: 0, | ||||
|     }) | ||||
|     expect(document.querySelectorAll('.ant-notification').length).toBe(1) | ||||
|   }) | ||||
| }) | ||||
|  |  | |||
|  | @ -8,9 +8,8 @@ describe('Notification.placement', () => { | |||
|     return document.body.querySelectorAll(className) | ||||
|   } | ||||
| 
 | ||||
|   function getStyle (el, prop, getComputedStyle, style) { | ||||
|     getComputedStyle = getComputedStyle || window.getComputedStyle | ||||
|     style = getComputedStyle ? getComputedStyle(el) : el.currentStyle | ||||
|   function getStyle (el, prop) { | ||||
|     const style = window.getComputedStyle ? window.getComputedStyle(el) : el.currentStyle | ||||
| 
 | ||||
|     // If a css property's value is `auto`, it will return an empty string.
 | ||||
|     return prop ? style[prop] : style | ||||
|  |  | |||
|  | @ -20,6 +20,9 @@ The simplest usage that close the notification box after 4.5s. | |||
|         this.$notification.open({ | ||||
|           message: 'Notification Title', | ||||
|           description: 'This is the content of the notification. This is the content of the notification. This is the content of the notification.', | ||||
|           onClick: () => { | ||||
|             console.log('Notification Clicked!'); | ||||
|           }, | ||||
|         }); | ||||
|       }, | ||||
|     } | ||||
|  |  | |||
|  | @ -23,6 +23,7 @@ The properties of config are as follows: | |||
| | placement | Position of Notification, can be one of `topLeft` `topRight` `bottomLeft` `bottomRight` | string | `topRight` | | ||||
| | style | Customized inline style | Object \| string | - | | ||||
| | onClose | Specify a function that will be called when the close button is clicked | Function | - | | ||||
| | onClick | Specify a function that will be called when the notification is clicked | Function | - | | ||||
| 
 | ||||
| `notification` also provides a global `config()` method that can be used for specifying the default options. Once this method is used, all the notification boxes will take into account these globally defined options when displaying. | ||||
| 
 | ||||
|  |  | |||
|  | @ -157,6 +157,7 @@ function notice (args) { | |||
|       duration, | ||||
|       closable: true, | ||||
|       onClose: args.onClose, | ||||
|       onClick: args.onClick, | ||||
|       key: args.key, | ||||
|       style: args.style || {}, | ||||
|       class: args.class, | ||||
|  |  | |||
|  | @ -31,6 +31,7 @@ config 参数如下: | |||
| | placement | 弹出位置,可选 `topLeft` `topRight` `bottomLeft` `bottomRight` | string | topRight | | ||||
| | style | 自定义内联样式 | Object \| string | - | | ||||
| | onClose | 点击默认关闭按钮时触发的回调函数 | Function | - | | ||||
| | onClick | 点击通知时触发的回调函数 | Function | - | | ||||
| 
 | ||||
| 还提供了一个全局配置方法,在调用前提前配置,全局一次生效。 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 tangjinzhou
						tangjinzhou