@@ -41,23 +41,32 @@ Component(
41
41
undefined ,
42
42
{
43
43
/// #if ALIPAY
44
+ async deriveDataFromProps ( nextProps ) {
45
+ const [ visible , duration , animation ] = getValueFromProps ( this , [
46
+ 'visible' ,
47
+ 'duration' ,
48
+ 'animation' ,
49
+ ] ) ;
50
+ const enableAnimation = animation && duration > 0 ;
51
+
52
+ if (
53
+ nextProps . visible !== visible &&
54
+ enableAnimation &&
55
+ ! nextProps . visible &&
56
+ ! this . data . closing
57
+ ) {
58
+ this . setData ( { closing : true } ) ;
59
+ }
60
+ } ,
44
61
didUpdate ( prevProps ) {
45
62
const [ visible , duration , animation ] = getValueFromProps ( this , [
46
63
'visible' ,
47
64
'duration' ,
48
65
'animation' ,
49
66
] ) ;
50
67
const enableAnimation = animation && duration > 0 ;
51
- if ( prevProps . visible !== visible ) {
52
- if ( enableAnimation && ! visible ) {
53
- setTimeout ( ( ) => {
54
- // 这里需要用setTimeout包一下,解决支付宝小程序Picker中导致 targetId not match
55
- this . setData ( { closing : true } ) ;
56
- } ) ;
57
- }
58
- if ( ! enableAnimation ) {
59
- triggerEventOnly ( this , visible ? 'afterShow' : 'afterClose' ) ;
60
- }
68
+ if ( prevProps . visible !== visible && ! enableAnimation ) {
69
+ triggerEventOnly ( this , visible ? 'afterShow' : 'afterClose' ) ;
61
70
}
62
71
} ,
63
72
/// #endif
@@ -66,7 +75,7 @@ Component(
66
75
'visible' : function ( nextProps ) {
67
76
const { visible, duration, animation } = nextProps ;
68
77
const enableAnimation = animation && duration > 0 ;
69
- if ( enableAnimation && ! visible ) {
78
+ if ( enableAnimation && ! visible && ! this . data . closing ) {
70
79
this . setData ( { closing : true } ) ;
71
80
}
72
81
if ( ! enableAnimation ) {
0 commit comments