Solution for incorrect image path packaging in vue-cli
I used vue-cli to build a project for the first time. When I package and deploy the project to the server for the first time, the image cannot be loaded. I finally figured it out using the online method. Deploy a project to the server in two ways: one is to directly deploy the project to the root directory of the server, and the other is to deploy the project to the subdirectory of the server.
1. Deploy it to the root directory, for example, www. *****. com.
Find the index. js file in the config folder of the project.
Change the assetsPublicPath: '/' in the file to the following box.
This aims to change the absolute path to a relative path.
In the root directory
2. Put it in a subdirectory, such as www. ***. com/community/dist.
The first step is the same as the previous step.
If you still use a route, change the index file in the router folder
After packaging with the npm run build command, put the dist file in the community folder so that the image can be displayed.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.