1

我正在使用 Animated.ValueXY() 中的 getLayout() 方法。执行代码时,抛出错误“TypeError: position.getLayout is not a function”。谁能帮我解决这个问题?

  const [position, setposition] = useState(new Animated.ValueXY());
  const [swipeCardPosition, setSCposition] = useState(new Animated.ValueXY({
    x: 0,
    y: -SCREEN_HEIGHT - Constants.statusBarHeight
  }));
  const [index, setIndex] = useState({
    currentIndex: 0
  });
  const panResponder = useRef(PanResponder.create({.....})).current;
  
   return (
          <Animated.View
            key={item.id}
            style={swipeCardPosition.getLayout()}
            {...panResponder.panHandlers}
          >)
  

错误:在此处输入图像描述

4

0 回答 0