首页 > 解决方案 > 试图分配给只读属性反应本机错误

问题描述

我有以下(切换)功能:

toggleMenu = () => {
    const toValue = this.open ? 0 : 1;
    Animated.spring(this.animation, {
      toValue,
      friction: 5,
    }).start();
    this.open = !this.open;
  };

我收到“尝试分配给只读属性”错误。有人可以解释这是为什么,以及如何解决吗?谢谢!

标签: javascriptreactjsreact-native

解决方案


推荐阅读