gpt4 book ai didi

javascript - undefined 不是 'new Animated.valueXY()' 中的构造函数

转载 作者:行者123 更新时间:2023-11-30 07:20:52 24 4
gpt4 key购买 nike

我正在尝试实现刷卡。有人可以帮我解决这个错误吗

import React, { Component } from 'react';
import { Text, Animated, Dimensions, PanResponder } from 'react-native';

class AlbumDetail extends Component {
constructor(props) {
super(props);
console.log('print log 1');
const position = new Animated.valueXY();
console.log('print log 2');

const panResponder = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onPanResponderMove: (event, gesture) => {
position.setValue({ x: gesture.dx, y: gesture.dy });
},
onPanResponderRelease: (event, gesture) => {
if (gesture.dx > SWIPE_THRESHOLD) {
forcedSwipe('right');
} else if (gesture.dx < -SWIPE_THRESHOLD) {
forcedSwipe('left');
} else {
this.resetPosition();
}
}
});

this.state = { panResponder, position};
}

render() {
return (
<Animated.View
style={this.position.getLayout()}
{...this.state.panResponder.panHandlers}
>
{this.renderCard}
</Animated.View>
)}
}

日志错误显示了这一点

print log 1

Possible Unhandled Promise Rejection (id: 0): TypeError: undefined isnot a constructor (evaluating 'new _reactNative.Animated.valueXY()')

最佳答案

你在这一行中犯了错误:

new Animated.ValueXY() //capital V

请引用documentation更多详情

关于javascript - undefined 不是 'new Animated.valueXY()' 中的构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44883629/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com