the vue project runs normally after local npm run dev. In addition to the normal refresh of the home page, click other page refresh to jump to the 404 page
how to deal with it?
the vue project runs normally after local npm run dev. In addition to the normal refresh of the home page, click other page refresh to jump to the 404 page
how to deal with it?
because you use history mode for routing, if you want to run online, you need to set a default page with the back end, which is usually the home page of the current project
.vue-router default hash mode-uses URL's hash to simulate a full URL, so when the URL changes, the page does not reload.
when you use history mode, URL is like a normal url, such as http://yoursite.com/user/id, which also looks good!
however, to play this mode well, you still need background configuration support. Because our application is a single-page client application, if the background is not configured correctly, users will return 404 when they directly access http://oursite.com/user/id in the browser, which is not good-looking.
so, you need to add a candidate resource that covers all situations on the server side: if the URL does not match any static resources, you should return the same index.html page, which is the page on which your app depends.
ide/essentials/history-mode.html" rel= "nofollow noreferrer" > vue-router
in the devServer of webpack, historyApiFallback: true
lists the following scenarios:
devServer: {
...
historyApiFallback: true
}
/ / vue routing configuration history. Refresh page returns home.index
router.get ('*', 'home.index')
location / {
try_files $uri $uri/ / index.html
}
the ultimate goal is to return the request for refreshing the address to the index page
ide/essentials/history-mode.html-sharp%E5%90%8E%E7%AB%AF%E9%85%8D%E7%BD%AE%E4%BE%8B%E5%AD%90" rel=" nofollow noreferrer "> HTML5 History mode
are you using history mode? the official website gives the answer
.post your project routing settings, post the console error report
check whether the route is correct
would like to ask, has the landlord solved it? I have the same problem ~
for example, I used npm install amazeui to download a dependent amazeui . there are js and css, in this amazeui. At this time, I want to reference these js in vue to get css,. What should I do? Do not use the reference method of the folder path, plea...
as there are more and more routes, more and more components are introduced into router.js, and each particular page corresponds to a different component. is this a reasonable way to write? It feels weird ...
problem description There are many websites of document type. At present, vue-cli converts markdown files directly into pages through webpack plug-ins. There is a problem that each markdown file must be registered for routing, resulting in a huge rout...