current position:Home>Solution to the blank page of the project created by create react app after packaging
Solution to the blank page of the project created by create react app after packaging
2022-04-29 16:10:50【X Beichen North】
Problem description :
When we use create-react-app Scaffolding creates a react After the project , When the development of the project is completed, you will find that you want to package it , adopt npm run build When the project packaged by the command is accessed on the browser side, the page will be blank .
resolvent :
There are generally two solutions to such problems , The first and most common , When we open the browser console, we will find , When the home page is blank, the browser console will report a lot of 404 Resource request error , This situation is easy to solve , We only need to find the in the root directory of the project package.json Add a line of configuration to the , as follows :
"homepage": "./",
After adding this line of configuration, repackage and deploy , There is a good chance that it will solve the problem of page blank . However, there are many cases where there will still be blank pages , But at this time, we will find that the browser console does not report errors , Just the front page blank . At this time, we need to check the routing component in the code to see if there is any problem , If you are using components that are BrowserRouter, Then there will be problems when the project we packaged and deployed is parsed on the browser side , That is, there will be blank pages , At this time, we need to switch the routing component to HashRouter, as follows :
import { HashRouter as Router, Route } from 'react-router-dom';
Through the above optimization , We will find that the problem of page blank has been solved .
copyright notice
author[X Beichen North],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291427264046.html
The sidebar is recommended
- Software design pattern -- Chapter 3 structural pattern -- sharing element pattern
- Vue uses the online form of Excel in the front end of lucky sheet to import, display and export Excel files
- Vue uses echart to draw national maps and overlay charts
- Vue + element UI: Vue user-defined instruction monitors the scrolling event of El table to scroll the scroll bar to the bottom and load new data
- Vue + element when there is no paging at the back end, the front end completes the paging of El table independently - scrolling to the bottom to load new data
- [react] react routing concept
- Lenovo z475 disassembly and repair - plate No. kl6c
- Random array into an array, requiring that the elements cannot be repeated
- The belated Toyota bz4x, even with the blessing of e-tnga architecture, is still not worth starting
- In element plus, for example, how to change the checkbox status in the list by clicking on the header and selecting all
guess what you like
Crawler reverse advanced, using ast technology to restore JavaScript obfuscated code
Help, after changing the user name, the computer is useless and can't log in
Drag the left column of Vue and keep the right width unchanged; The scroll bar appears
HTML notes
In depth analysis of headless single linked list -- dynamic diagram demonstration of C language
Share 9 development skills related to vue3
CSS box centered
Used in Vue projects Sync modifier and $emit (update: XXX)
Vue class & Style binding and computed
Vue project uses this$ forceUpdate(); Force render page
Random recommended
- HTTP becomes HTTPS, self-made certificate
- Web front-end operation - tourism enterprise marketing publicity responsive website template (HTML + CSS + JavaScript)
- Self inspection list of a [qualified] front-end Engineer
- This principle in JavaScript and six common usage scenarios
- JavaScript this priority
- Analyzing the principle of HTTPS encryption
- Difference and principle between websocket and http
- Use of elementui scroll bar component El scrollbar
- Nginx security optimization
- GAC group has become the first pilot enterprise of "yueyouhang". Blessed are the car owners in Guangdong!
- Loki HTTP API usage
- JavaScript - prototype, prototype chain
- Front end experience
- JavaScript -- Inheritance
- HTTP cache
- Filters usage of table in elementui
- A JavaScript pit encountered by a non front-end siege lion
- Grain College - image error when writing Vue with vscode
- Utility gadget - get the IP address in the HTTP request
- Could not fetch URL https://pypi.org/simple/pytest-html/: There was a problem confirming the ssl cer
- Function of host parameter in http
- Use nginx proxy node red under centos7 and realize password access
- Centos7 nginx reverse proxy TCP port
- In eclipse, an error is reported when referencing layuijs and CSS
- Front end online teacher Pink
- Learn to use PHP to insert elements at the specified position and key of the array
- Learn how to use HTML and CSS styles to overlay two pictures on another picture to achieve the effect of scanning QR code by wechat
- Learn how to use CSS to vertically center the content in Div
- Learn how to use CSS to circle numbers
- Learn to open and display PDF files in HTML web pages
- The PHP array random sorting function shuffle() randomly scrambles the order of array elements
- JQuery implements the keyboard enter search function
- 16 ArcGIS API for JavaScript 4.18 a new development method based on ES modules @ ArcGIS / core
- 17 ArcGIS API for JavaScript 4.18 draw points, lines and faces with the mouse
- 18 ArcGIS API for JavaScript 4.18 obtain the length and area after drawing line segments and surface features
- Vue environment construction -- scaffold
- Build a demo with Vue scaffold
- Using vuex in Vue projects
- Use Vue router in Vue project
- 26 [react basics-5] react hook