加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

动画 – 无法将React Native Animated值设置为View组件CSS样式

发布时间:2020-12-15 09:33:22 所属栏目:百科 来源:网络整理
导读:我正在尝试使用View组件样式动画.我按照这里列出的例子: https://facebook.github.io/react-native/docs/animations.html 但是,当我渲染我的组件时,我得到错误: [tid:com.facebook.React.ShadowQueue][RCTConvert.m:55] Error setting property ‘height’
我正在尝试使用View组件样式动画.我按照这里列出的例子: https://facebook.github.io/react-native/docs/animations.html

但是,当我渲染我的组件时,我得到错误:

[tid:com.facebook.React.ShadowQueue][RCTConvert.m:55] Error setting property ‘height’ of RCTView with tag #7: JSON value ‘{
“_animation” = “”;
“_children” = (
);
“_listeners” = {
};
“_offset” = 0;
“_value” = 200;
}’ of type NSDictionary cannot be converted to NSNumber

这就是我在构造函数中设置Animated值的方法:

constructor() {
    super();
    this.state = {
      titleContainerHeight: new Animated.Value(200),}
  }

以下是我的看法:

<View style={[styles.titleContainer,{height:this.state.titleContainerHeight}]}>
  <Text style={[{color: 'white'}]}>App logo here</Text>
</View>

好像我正在处理文档描述的所有内容,而且我在另一个组件中做同样的事情而没有出现任何错误.那么,这里有什么问题?

解决方法

啊没关系,我发现我做错了什么.我忘了专门使用“Animated.View”组件.这有效:

<Animated.View style={[styles.titleContainer,{height:this.state.titleContainerHeight}]}>
  <Text style={[{color: 'white'}]}>App logo here</Text>
</Animated.View>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读