mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 17:51:54 +00:00
feat: update toast&switch
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Vue from 'vue';
|
||||
import merge from 'src/utils/merge';
|
||||
|
||||
const ToastConstructor = Vue.extend(require('./toast.vue'));
|
||||
let toastQueue = [];
|
||||
@@ -50,4 +51,26 @@ var Toast = (options = {}) => {
|
||||
return instance;
|
||||
};
|
||||
|
||||
Toast.loading = (options) => {
|
||||
return new Toast(merge({
|
||||
type: 'loading'
|
||||
}, options));
|
||||
};
|
||||
|
||||
Toast.success = (options) => {
|
||||
const message = typeof options === 'string' ? options : options.message;
|
||||
return new Toast(merge({
|
||||
type: 'success',
|
||||
message: message
|
||||
}, options));
|
||||
};
|
||||
|
||||
Toast.fail = (options) => {
|
||||
const message = typeof options === 'string' ? options : options.message;
|
||||
return new Toast(merge({
|
||||
type: 'fail',
|
||||
message: message
|
||||
}, options));
|
||||
};
|
||||
|
||||
export default Toast;
|
||||
|
@@ -22,7 +22,7 @@
|
||||
import zanLoading from 'packages/loading';
|
||||
import zanIcon from 'packages/icon';
|
||||
|
||||
const TOAST_TYPES = ['text', 'loading', 'success', 'failure'];
|
||||
const TOAST_TYPES = ['text', 'loading', 'success', 'fail'];
|
||||
/**
|
||||
* zan-toast
|
||||
* @module components/toast
|
||||
@@ -50,7 +50,7 @@ export default {
|
||||
type: String,
|
||||
default: '',
|
||||
validate(value) {
|
||||
if (this.type === 'success' || this.type === 'failure') {
|
||||
if (this.type === 'success' || this.type === 'fail') {
|
||||
return value.length <= 16;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user