feat(Tabbar): add before-change prop (#7081)

This commit is contained in:
neverland
2020-09-02 11:45:11 +08:00
committed by GitHub
parent b276fb5a78
commit d55585314f
5 changed files with 90 additions and 3 deletions
+11 -3
View File
@@ -1,6 +1,7 @@
import { createNamespace } from '../utils';
import { ParentMixin } from '../mixins/relation';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
import { callInterceptor } from '../utils/interceptor';
import { ParentMixin } from '../mixins/relation';
const [createComponent, bem] = createNamespace('tabbar');
@@ -12,6 +13,7 @@ export default createComponent({
zIndex: [Number, String],
placeholder: Boolean,
activeColor: String,
beforeChange: Function,
inactiveColor: String,
value: {
type: [Number, String],
@@ -67,8 +69,14 @@ export default createComponent({
onChange(active) {
if (active !== this.value) {
this.$emit('input', active);
this.$emit('change', active);
callInterceptor({
interceptor: this.beforeChange,
args: [active],
done: () => {
this.$emit('input', active);
this.$emit('change', active);
},
});
}
},