我在vue中工作,当查看页面时,链接显示如下:
http://localhost:8080/#/
http://localhost:8080/#/categorias我该怎么移除它?
所以看起来像这样?
http://localhost:8080/categorias
http://localhost:8080/这是我的js路由器
import { createRouter, createWebHashHistory } from 'vue-router'
//import Home from '../views/Home.vue'
import Inicio from '../components/Inicio.vue'
const routes = [
{
path: '/',
name: 'inicio',
component: Inicio
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
},
{
path: '/categorias',
name: 'Categorias',
component: () => import(/* webpackChunkName: "about" */ '../components/Categorias.vue')
},
{
path: '/login',
name: 'Login',
component: () => import(/* webpackChunkName: "about" */ '../components/Login.vue')
}
]
const router = createRouter({
history: createWebHashHistory(),
routes
})
export default router谢谢您的帮助,因为我还没能解决这个问题,如果有这样的网址,我会感到很不舒服。
发布于 2021-10-18 20:21:46
发布于 2021-10-19 02:27:17
vue
import VueRouter from 'vue-router'
const router = new VueRouter({
routes,
mode:'history'
})nginx :当您在web服务(例如:linux)上部署它时,.you显示添加此配置
server {
listen 80;
server_name localhost;
server_name_in_redirect off;
location / {
root /etc/nginx/html; // deploy html path
index index.html index.htm;
if (-d $request_filename) {
rewrite ^/(.*) /index.html break;
}
if (!-e $request_filename) {
rewrite ^/(.*) /index.html break;
}
} https://stackoverflow.com/questions/69622067
复制相似问题