Commit ab249f70594b1052deb71ce8a21c45cc004f8b51
Committed by
GitHub
Merge pull request #677 from lcx960324/2.0
bugfix on Message
Showing
3 changed files
with
11 additions
and
2 deletions
Show diff stats
examples/routers/message.vue
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | <i-button @click.native="success">显示成功提示</i-button> |
| 4 | 4 | <i-button @click.native="warning">显示警告提示</i-button> |
| 5 | 5 | <i-button @click.native="error">显示错误提示</i-button> |
| 6 | + <i-button @click.native="destroy">销毁提示</i-button> | |
| 6 | 7 | </div> |
| 7 | 8 | </template> |
| 8 | 9 | <script> |
| ... | ... | @@ -16,6 +17,9 @@ |
| 16 | 17 | }, |
| 17 | 18 | error () { |
| 18 | 19 | this.$Message.error('对方不想说话,并且向你抛出了一个异常'); |
| 20 | + }, | |
| 21 | + destroy () { | |
| 22 | + this.$Message.destroy(); | |
| 19 | 23 | } |
| 20 | 24 | } |
| 21 | 25 | } | ... | ... |
src/components/base/notification/index.js
| ... | ... | @@ -29,7 +29,10 @@ Notification.newInstance = properties => { |
| 29 | 29 | }, |
| 30 | 30 | component: notification, |
| 31 | 31 | destroy () { |
| 32 | - document.body.removeChild(div); | |
| 32 | + notification.closeAll(); | |
| 33 | + setTimeout(function() { | |
| 34 | + document.body.removeChild(document.getElementsByClassName('ivu-message')[0].parentElement); | |
| 35 | + }, 500); | |
| 33 | 36 | } |
| 34 | 37 | }; |
| 35 | 38 | }; | ... | ... |
src/components/base/notification/notification.vue
| ... | ... | @@ -81,13 +81,15 @@ |
| 81 | 81 | }, |
| 82 | 82 | close (name) { |
| 83 | 83 | const notices = this.notices; |
| 84 | - | |
| 85 | 84 | for (let i = 0; i < notices.length; i++) { |
| 86 | 85 | if (notices[i].name === name) { |
| 87 | 86 | this.notices.splice(i, 1); |
| 88 | 87 | break; |
| 89 | 88 | } |
| 90 | 89 | } |
| 90 | + }, | |
| 91 | + closeAll () { | |
| 92 | + this.notices = []; | |
| 91 | 93 | } |
| 92 | 94 | } |
| 93 | 95 | }; | ... | ... |