mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-05 19:41:45 +08:00
[improvement] Tabbar: optimize performance (#547)
This commit is contained in:
parent
aae778e368
commit
19a0c000a1
4
dist/col/index.js
vendored
4
dist/col/index.js
vendored
@ -16,7 +16,9 @@ create({
|
||||
setGutter(gutter) {
|
||||
const padding = `${gutter / 2}px`;
|
||||
const style = gutter ? `padding-left: ${padding}; padding-right: ${padding};` : '';
|
||||
this.setData({ style });
|
||||
if (style !== this.data.style) {
|
||||
this.setData({ style });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
7
dist/tabbar-item/index.js
vendored
7
dist/tabbar-item/index.js
vendored
@ -25,6 +25,13 @@ create({
|
||||
parent.onChange(this);
|
||||
}
|
||||
this.$emit('click');
|
||||
},
|
||||
|
||||
setActive(data) {
|
||||
const { active, count } = this.data;
|
||||
if (active !== data.active || count !== data.count) {
|
||||
this.setData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
10
dist/tabbar/index.js
vendored
10
dist/tabbar/index.js
vendored
@ -34,12 +34,16 @@ create({
|
||||
|
||||
linked(target) {
|
||||
this.data.items.push(target);
|
||||
this.setActiveItem();
|
||||
setTimeout(() => {
|
||||
this.setActiveItem();
|
||||
});
|
||||
},
|
||||
|
||||
unlinked(target) {
|
||||
this.data.items = this.data.items.filter(item => item !== target);
|
||||
this.setActiveItem();
|
||||
setTimeout(() => {
|
||||
this.setActiveItem();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -47,7 +51,7 @@ create({
|
||||
methods: {
|
||||
setActiveItem() {
|
||||
this.data.items.forEach((item, index) => {
|
||||
item.setData({
|
||||
item.setActive({
|
||||
active: index === this.data.currentActive,
|
||||
count: this.data.items.length
|
||||
});
|
||||
|
@ -16,7 +16,9 @@ create({
|
||||
setGutter(gutter) {
|
||||
const padding = `${gutter / 2}px`;
|
||||
const style = gutter ? `padding-left: ${padding}; padding-right: ${padding};` : '';
|
||||
this.setData({ style });
|
||||
if (style !== this.data.style) {
|
||||
this.setData({ style });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -25,6 +25,13 @@ create({
|
||||
parent.onChange(this);
|
||||
}
|
||||
this.$emit('click');
|
||||
},
|
||||
|
||||
setActive(data) {
|
||||
const { active, count } = this.data;
|
||||
if (active !== data.active || count !== data.count) {
|
||||
this.setData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -34,12 +34,16 @@ create({
|
||||
|
||||
linked(target) {
|
||||
this.data.items.push(target);
|
||||
this.setActiveItem();
|
||||
setTimeout(() => {
|
||||
this.setActiveItem();
|
||||
});
|
||||
},
|
||||
|
||||
unlinked(target) {
|
||||
this.data.items = this.data.items.filter(item => item !== target);
|
||||
this.setActiveItem();
|
||||
setTimeout(() => {
|
||||
this.setActiveItem();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -47,7 +51,7 @@ create({
|
||||
methods: {
|
||||
setActiveItem() {
|
||||
this.data.items.forEach((item, index) => {
|
||||
item.setData({
|
||||
item.setActive({
|
||||
active: index === this.data.currentActive,
|
||||
count: this.data.items.length
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user