ReactJS Navigate to a Blank Page - Simple Guide with Example
In ReactJS, you can navigate to a blank page by using the window.location object to change the URL of the current page. Here's an example: \n\njsx\nimport React from \"react\";\n\nfunction BlankPage() {\n const navigateToBlankPage = () => {\n window.location.href = \"/blank\"; // Replace \"/blank\" with the desired URL of the blank page\n };\n\n return (\n <div>\n <h1>Click the button to navigate to a blank page</h1>\n <button onClick={navigateToBlankPage}>Go to Blank Page</button>\n </div>\n );\n}\n\nexport default BlankPage;\n\n\nWhen the button is clicked, the navigateToBlankPage function will be called, which changes the URL to the specified blank page.
原文地址: https://www.cveoy.top/t/topic/pTrC 著作权归作者所有。请勿转载和采集!