[英]when I clicking on Back button of browser , it should go to the previous activity of the same page
[英]In React, On clicking browser back button I should click one DOM ele(for instance, button) and should be in the same component
window.addEventListener('beforeunload', () => {
document.getElementById('sample-button').click()
})
應該添加哪個事件監聽器?
如果您正在使用類組件,例如
class pp extends React.Component {
//This method is called when a component is being removed from the DOM:
componentWillUnmount()
{
document.getElementById('sample-button').click()
}
render(){
return ...
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.