我正在使用 ReactStrap 中的 ButtonGroup 和 Button。当您单击其中一个按钮时,我设置了一个 onClick 函数:
< ButtonGroup >
<Button>Edit</Button>
<Button onClick={console.log("Print some text")}>Print text</Button>
<Button>Set as default</Button>
</ButtonGroup >
But when I load the page this is what I get:
在我点击按钮之前。如果我点击它,控制台中什么也不会出现。有任何想法吗?
Onclick 必须是函数。您只需设置 onclick 作为结果console.log("Print some text")
Try this
<Button onClick={() => {console.log("Print some text")}}>Print text</Button>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)