首页 > 解决方案 > 尝试查看输出时如何使用 console.log?

问题描述

例如,声明activeTabIndex

如何查看我是否设置了 activeTabIndex 事件?

这是代码:

 <TouchableOpacity onPress={() => setActiveTabIndex(0)} style={{ width: Dimensions.get("window").width / 4, padding: 5, alignItems: "center" }}>
          <Home height={30} width={22} fill={activeTabIndex == 0 ? "blue" : "#d4e6f1"} />
        </TouchableOpacity>

在哪里写 console.log(activeTabIndex) 什么的)

标签: javascriptreact-native

解决方案


  1. 您可以将 activeTabIndex 绑定到您的 JSX 模板,例如。{activeTabIndex}
  2. 您可以在setActiveTabIndex()方法中添加一个 console.log(index) 以查看它是否被触发。

推荐阅读