Solution for incorrect image path packaging in vue-cli

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.