Throw the dist generated by packaging the vue project to the server, and find that the resource cannot be accessed?

        After writing the vue project, there is no problem with the local test. Now I want other people to access it on the public network, so I naturally need to use the cloud server. I am currently using Tencent Cloud and adding a Pagoda panel, which is very convenient.

        The problem that arises is that my project has no problems locally, but when I throw it on the server, I find that the css, js and img in the dist are all 404 not found. After reading it in the browser's debugging tool, I found out that the request was made The path is not quite correct. It seems that there is one path missing, that is, /dist is missing. Of course, it is just my guess now.

        Solution: Let’s practice according to the conjecture and modify the path in vue.config.js, because I am also a newcomer and have been stepping on the pit. I guess the path here is related to webpack, that is, after packaging Dist is related, so I added a line of code: publicPath:'./' , then npm run build again, and then threw the packaged dist on the server, so the problem was solved.

Code screenshot of my vue.config.js:

 

 

Guess you like

Origin blog.csdn.net/qq_41083105/article/details/119389286