feat: add tests && fix bugs
This commit is contained in:
@@ -11,12 +11,18 @@
|
||||
* <zan-button size="large" type="primary">按钮</zan-button>
|
||||
*/
|
||||
|
||||
import ZanLoading from 'packages/loading';
|
||||
|
||||
const ALLOWED_SIZE = ['mini', 'small', 'normal', 'large'];
|
||||
const ALLOWED_TYPE = ['default', 'danger', 'primary'];
|
||||
|
||||
export default {
|
||||
name: 'zan-button',
|
||||
|
||||
components: {
|
||||
'zan-loading': ZanLoading
|
||||
},
|
||||
|
||||
props: {
|
||||
disabled: Boolean,
|
||||
loading: Boolean,
|
||||
@@ -45,6 +51,7 @@ export default {
|
||||
|
||||
methods: {
|
||||
handleClick(e) {
|
||||
if (this.loading || this.disabled) return;
|
||||
this.$emit('click', e);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -53,7 +53,7 @@ export default {
|
||||
type: {
|
||||
type: String,
|
||||
default: 'text',
|
||||
validate(value) {
|
||||
validator(value) {
|
||||
return VALID_TYPES.indexOf(value) > -1;
|
||||
}
|
||||
},
|
||||
@@ -71,7 +71,7 @@ export default {
|
||||
autosize: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
validate(value) {
|
||||
validator(value) {
|
||||
if (value && this.type !== 'textarea') return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@ export default {
|
||||
type: {
|
||||
type: String,
|
||||
default: 'gradient-circle',
|
||||
validate(value) {
|
||||
validator(value) {
|
||||
return VALID_TYPES.indexOf(value) > -1;
|
||||
}
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: 'black',
|
||||
validate(value) {
|
||||
validator(value) {
|
||||
return VALID_COLORS.indexOf(value) > -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export default {
|
||||
percentage: {
|
||||
type: Number,
|
||||
required: true,
|
||||
validate(value) {
|
||||
validator(value) {
|
||||
return value <= 100 && value >= 0;
|
||||
}
|
||||
},
|
||||
@@ -55,9 +55,6 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
currentPivotText() {
|
||||
return this.pivotText ? this.pivotText : this.percentage + '%';
|
||||
},
|
||||
componentColor() {
|
||||
return this.inactive ? INACTIVE_COLOR : this.color;
|
||||
},
|
||||
|
||||
@@ -62,7 +62,6 @@ export default {
|
||||
*/
|
||||
toggleState: function() {
|
||||
if (this.disabled || this.loading) return;
|
||||
console.log('d');
|
||||
if (this.onChange) {
|
||||
this.onChange(!this.checked);
|
||||
} else {
|
||||
|
||||
@@ -50,14 +50,14 @@ export default {
|
||||
type: {
|
||||
type: String,
|
||||
default: 'text',
|
||||
validate(value) {
|
||||
validator(value) {
|
||||
return TOAST_TYPES.indexOf(value) > -1;
|
||||
}
|
||||
},
|
||||
message: {
|
||||
type: String,
|
||||
default: '',
|
||||
validate(value) {
|
||||
validator(value) {
|
||||
if (this.type === 'success' || this.type === 'fail') {
|
||||
return value.length <= 16;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user