@@ -114,42 +114,48 @@ export default class AtNoticebar extends React.Component<
114
114
}
115
115
116
116
public render ( ) : JSX . Element | boolean {
117
- const { single, icon, marquee, customStyle } = this . props
117
+ const {
118
+ single,
119
+ icon,
120
+ marquee,
121
+ customStyle,
122
+ className,
123
+ moreText = '查看详情'
124
+ } = this . props
118
125
let { showMore, close } = this . props
119
- const { dura } = this . state
126
+ const {
127
+ dura,
128
+ show,
129
+ animElemId,
130
+ animationData,
131
+ isWEAPP,
132
+ isALIPAY
133
+ } = this . state
120
134
const rootClassName = [ 'at-noticebar' ]
121
- let _moreText = this . props . moreText
122
135
123
136
if ( ! single ) showMore = false
124
137
125
- if ( ! _moreText ) _moreText = '查看详情'
126
-
127
138
const style = { }
128
139
const innerClassName = [ 'at-noticebar__content-inner' ]
129
140
if ( marquee ) {
130
141
close = false
131
142
style [ 'animation-duration' ] = `${ dura } s`
132
- innerClassName . push ( this . state . animElemId )
143
+ innerClassName . push ( animElemId )
133
144
}
134
145
135
146
const classObject = {
136
147
'at-noticebar--marquee' : marquee ,
137
- 'at-noticebar--weapp' :
138
- marquee && ( this . state . isWEAPP || this . state . isALIPAY ) ,
148
+ 'at-noticebar--weapp' : marquee && ( isWEAPP || isALIPAY ) ,
139
149
'at-noticebar--single' : ! marquee && single
140
150
}
141
151
142
152
const iconClass = [ 'at-icon' ]
143
153
if ( icon ) iconClass . push ( `at-icon-${ icon } ` )
144
154
145
155
return (
146
- this . state . show && (
156
+ show && (
147
157
< View
148
- className = { classNames (
149
- rootClassName ,
150
- classObject ,
151
- this . props . className
152
- ) }
158
+ className = { classNames ( rootClassName , classObject , className ) }
153
159
style = { customStyle }
154
160
>
155
161
{ close && (
@@ -169,12 +175,8 @@ export default class AtNoticebar extends React.Component<
169
175
) }
170
176
< View className = 'at-noticebar__content-text' >
171
177
< View
172
- id = { this . state . animElemId }
173
- animation = { {
174
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
175
- // @ts -ignore
176
- actions : this . state . animationData
177
- } }
178
+ id = { animElemId }
179
+ animation = { animationData }
178
180
className = { classNames ( innerClassName ) }
179
181
style = { style }
180
182
>
@@ -187,7 +189,7 @@ export default class AtNoticebar extends React.Component<
187
189
className = 'at-noticebar__more'
188
190
onClick = { this . onGotoMore . bind ( this ) }
189
191
>
190
- < Text className = 'text' > { _moreText } </ Text >
192
+ < Text className = 'text' > { moreText } </ Text >
191
193
< View className = 'at-noticebar__more-icon' >
192
194
< Text className = 'at-icon at-icon-chevron-right' > </ Text >
193
195
</ View >
0 commit comments