Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of incorrect default route after packaging and deployment of vue project

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to solve the incorrect default route after the vue project is packaged and deployed". In the operation of the actual case, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Problem description of incorrect default route after package deployment

The default route is fine when the vue project is developed locally, for example

Redirect: "/ index"

However, after deployment, the default route on the server is incorrect, and the problem now is that it will jump to the login page by default, provided that the project does not have routing permission.

Solution

Open the routing index.js file and add: base: "/"

Const routers = new Router ({mode: "history", base: "/"})

Package and publish to the server again and find that the problem is solved.

The path of vue is incorrect after packing.

1. View the scripts command of package.json file

2. Open the webpack.dev.conf.js file, find publicPath: config.dev.assetsPublicPath, press Ctrl and click to jump to the index.js file.

3. Where dev is the development environment and build is the construction version, find the assetsPublicPath:'/ 'under build, and then change it to assetsPublicPath:'. /', that is, add a point before "/".

4. The terminal can run npm run build.

For the problem that the background picture is not displayed

Project directory > build folder > utils.js

The animation cannot be run

Vue-cli scaffolding package.json profile

"browserslist": ["> 1%", "last 5 versions", "Android > = 4.0", "not ie"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report