feat: update toast&switch

This commit is contained in:
jiangruowei
2017-03-17 11:30:53 +08:00
parent 9ccce7cd5c
commit 25ce414de2
6 changed files with 101 additions and 27 deletions

View File

@@ -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;

View File

@@ -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;
}
}