Skip to content

Commit 4be1e88

Browse files
authored
fix(swipe-cell): enable dynaimc props (#2239)
1 parent 62c2d26 commit 4be1e88

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/swipe-cell/swipe-cell.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,25 @@ export default class SwiperCell extends SuperComponent {
2626
classPrefix: name,
2727
};
2828

29-
attached() {
30-
ARRAY.push(this as WechatMiniprogram.Component.TrivialInstance);
31-
}
29+
observers = {
30+
'left, right'() {
31+
this.setSwipeWidth();
32+
},
33+
};
3234

33-
ready() {
34-
this.setSwipeWidth();
35-
}
35+
lifetimes = {
36+
attached() {
37+
ARRAY.push(this as WechatMiniprogram.Component.TrivialInstance);
38+
},
39+
40+
ready() {
41+
this.setSwipeWidth();
42+
},
43+
44+
detached() {
45+
ARRAY = ARRAY.filter((item) => item !== this);
46+
},
47+
};
3648

3749
setSwipeWidth() {
3850
Promise.all([getRect(this, `${ContainerClass}__left`), getRect(this, `${ContainerClass}__right`)]).then(
@@ -45,10 +57,6 @@ export default class SwiperCell extends SuperComponent {
4557
);
4658
}
4759

48-
detached() {
49-
ARRAY = ARRAY.filter((item) => item !== this);
50-
}
51-
5260
open() {
5361
this.setData({ opened: true });
5462
}

0 commit comments

Comments
 (0)