Commit d367168798bdaa82706f96304ac999b8af89d506
1 parent
47e58396
add destroy() for message component
add destroy() for message component
Showing
3 changed files
with
10 additions
and
1 deletions
Show diff stats
components/message/index.js
... | ... | @@ -89,5 +89,10 @@ export default { |
89 | 89 | if (options.duration) { |
90 | 90 | defaultDuration = options.duration; |
91 | 91 | } |
92 | + }, | |
93 | + destroy () { | |
94 | + let instance = getMessageInstance(); | |
95 | + messageInstance = null; | |
96 | + instance.destroy(); | |
92 | 97 | } |
93 | 98 | } |
94 | 99 | \ No newline at end of file | ... | ... |
local/routers/msg.vue
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | <Button @click="error">error</Button> |
5 | 5 | <Button @click="warning">warning</Button> |
6 | 6 | <Button @click="loading">手动消失</Button> |
7 | + <Button @click="destroy">destroy</Button> | |
7 | 8 | </template> |
8 | 9 | <script> |
9 | 10 | import { Message, Button } from 'iview'; |
... | ... | @@ -45,6 +46,9 @@ |
45 | 46 | const hide = Message.loading('我是loading', 0); |
46 | 47 | |
47 | 48 | setTimeout(hide, 5000); |
49 | + }, | |
50 | + destroy () { | |
51 | + Message.destroy(); | |
48 | 52 | } |
49 | 53 | }, |
50 | 54 | ready () { | ... | ... |