[英]React window is not closing when the user clicks the button
I open a React web app like this in my index.js file:我在 index.js 文件中打开一个 React web 应用程序,如下所示:
ReactDOM.render(
<React.Fragment>
<Review pplNum={num} />
</React.Fragment>,
document.getElementById('root')
)
I then want the user to be able to close it, but close button doesn't work.然后我希望用户能够关闭它,但关闭按钮不起作用。
Here is the Review component:这是评论组件:
import React, { useEffect } from "react";
import axios from 'axios';
const Review = ({ pplNum }) => {
axios.put('/books/reviews/' + pplNum)
.then(res => console.log(res.data));
return (
<div>
<div>Thank you for the review</div>
<div><a href="javascript:window.close">Click here to close</a> this window</div>
</div>
);
}
export default Review;
When I click it to close, nothing happens.当我单击它关闭时,什么也没有发生。
Is there something I am not doing correctly?有什么我做的不对吗?
Thanks!谢谢!
You're not calling it as a function:您不会将其称为 function:
<a href="javascript:window.close()">Click here to close</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.