first commit
This commit is contained in:
27
uni_modules/tdesign-uniapp/components/toast/index.js
Normal file
27
uni_modules/tdesign-uniapp/components/toast/index.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { getInstance, coalesce } from '../common/utils';
|
||||
|
||||
|
||||
function Toast(options) {
|
||||
const { context, selector = '#t-toast', ...Options } = options;
|
||||
const instance = getInstance(context, selector);
|
||||
if (instance) {
|
||||
instance.show({
|
||||
...Options,
|
||||
duration: coalesce(Options.duration, 2000),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showToast(options = {}) {
|
||||
Toast(options);
|
||||
}
|
||||
|
||||
function hideToast(options = {}) {
|
||||
const { context, selector = '#t-toast' } = options;
|
||||
const instance = getInstance(context, selector);
|
||||
if (instance) {
|
||||
instance.hide();
|
||||
}
|
||||
}
|
||||
|
||||
export { Toast as default, showToast, hideToast };
|
||||
Reference in New Issue
Block a user