【发布时间】:2021-09-10 12:12:15
【问题描述】:
例如,声明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)什么的)
【问题讨论】:
-
{activeTabIndex}在 JSX 开始和结束标记之间... -
在开发者工具上,console.log(activeTabIndex) 不起作用
-
您不必使用
console.log,只需在HTML 中使用{activeTabIndex},该值就会打印在HTML 中。 -
在
setActiveTabIndex函数中有console.log(whateverVarIsPassed) -
这没有任何意义。 - 如果需要,您可以执行 console.log(setTabIndex (activeTabIndex)) 并返回 tabIndex,但反之则不行