简体   繁体   English

为什么我的 React js 按钮 onMouseDown 不起作用?

[英]Why isn't my React js button onMouseDown not working?

<div className="commentinputMain">
                <img
                    className="commentinputPic"
                    src={PF + user.profilePic}
                    alt="Profile Pic"
                />
                <input
                    className="commentinputInputMain"
                    placeholder="Share something!"
                    onMouseDown={displayButtons}
                    onChange={(e) => {
                        setText(e.target.value);
                        setShowButtons(true);
                    }} />
            </div>
            <div className="commentinputMain">
                {showButtons && (
                    <>
                        <p>
                            <button onMouseDown={console.log("Wait WHAT??")}>Cancel</button>
                        </p>
                        <button>Post</button>
                    </>
                )}
            </div>
            <hr className="commentinputh1" />

Why is the Cancel on click not working?为什么点击取消不起作用? Please give me a solution.请给我一个解决方案。 I am using React JS and am creating a blog website我正在使用 React JS 并且正在创建一个博客网站

你不能像这样调用 console.log 试试这样让我知道这是否有效

onMouseDown={()=>console.log("Wait WHAT??")}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM