1

我正在尝试将风格传递给孩子,我的代码是:

render() {
    const RotateData = this.RotateValueHolder.interpolate({
        inputRange: [0, 1],
        outputRange: ['0deg', '360deg']
    });

    Object.assign(this.props.children.props.style,{'transform': [{'rotate': RotateData}] });

    return (
        <View style={{flex:1}}>
            {this.props.children}
        </View>
    );
}

我收到此错误:

Invariant Violation: Transform with key of "rotate" must be a string:
{"rotate":"0deg"}
4

1 回答 1

1

Rotate 只能由动画组件使用,因此您需要将样式应用于 Animated.View 或任何 Animated 元素。所以尝试将它与动画组件一起使用。

于 2018-01-31T09:34:51.670 回答