【发布时间】:2021-04-08 17:44:58
【问题描述】:
我在反应中使用 Chakra UI,当我尝试单击可点击框中的按钮时,正在执行框的功能。 Z-index 也没有解决问题。
我的代码:
<Box
w="90%"
h="auto"
mt="10px"
position="relative"
key={index}
borderWidth="1px"
borderRadius="lg"
onClick={() =>
history.push(`/products/${item.cat_name}/${item.id}`)}
>
<h1 className={styles.heading_bold}>{item.cat_name}</h1>
<Button position="absolute" top="3" right="3" zIndex="0"> //Button not able to click
Options
</Button
</Box>
【问题讨论】:
-
请在codesandbox中添加示例代码以便调试更好
-
因为
event bubbling。如果你想阻止它,你需要停止它的传播。阅读更多相关信息 -
@A.R.SEIF 代码框链接在这里codesandbox.io/s/loving-euler-z10mn?file=/src/app.js
标签: html css reactjs jsx chakra-ui