mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 11:17:41 +00:00
feat: add clear method
This commit is contained in:
@@ -139,10 +139,10 @@ import { Toast } from 'src/index';
|
|||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
showToast() {
|
showToast() {
|
||||||
this.toast = Toast('我是提示文案,建议不超过十五字~');
|
Toast('我是提示文案,建议不超过十五字~');
|
||||||
},
|
},
|
||||||
closeToast() {
|
closeToast() {
|
||||||
this.toast.clear();
|
Toast.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -5,9 +5,8 @@ const ToastConstructor = Vue.extend(require('./toast.vue'));
|
|||||||
let instance;
|
let instance;
|
||||||
|
|
||||||
const getInstance = () => {
|
const getInstance = () => {
|
||||||
if (instance) {
|
if (instance) instance.clear();
|
||||||
instance.clear();
|
|
||||||
}
|
|
||||||
instance = new ToastConstructor({
|
instance = new ToastConstructor({
|
||||||
el: document.createElement('div')
|
el: document.createElement('div')
|
||||||
});
|
});
|
||||||
@@ -70,4 +69,8 @@ Toast.fail = (options) => {
|
|||||||
}, options));
|
}, options));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Toast.clear = () => {
|
||||||
|
if (instance) instance.clear();
|
||||||
|
}
|
||||||
|
|
||||||
export default Toast;
|
export default Toast;
|
||||||
|
Reference in New Issue
Block a user