feat: add clear method

This commit is contained in:
jiangruowei 2017-03-30 17:26:49 +08:00
parent 9e0a6bb984
commit e560cef315
2 changed files with 8 additions and 5 deletions

View File

@ -139,10 +139,10 @@ import { Toast } from 'src/index';
export default {
methods: {
showToast() {
this.toast = Toast('我是提示文案,建议不超过十五字~');
Toast('我是提示文案,建议不超过十五字~');
},
closeToast() {
this.toast.clear();
Toast.clear();
}
}
};

View File

@ -5,9 +5,8 @@ const ToastConstructor = Vue.extend(require('./toast.vue'));
let instance;
const getInstance = () => {
if (instance) {
instance.clear();
}
if (instance) instance.clear();
instance = new ToastConstructor({
el: document.createElement('div')
});
@ -70,4 +69,8 @@ Toast.fail = (options) => {
}, options));
};
Toast.clear = () => {
if (instance) instance.clear();
}
export default Toast;