// 使用 Vue Router 的 history 模式
const router = new VueRouter({
mode: 'history',
routes: [
{ path: '/', component: Home },
{ path: '/about', component: About }
]
});
// 使用 Vue Router 的 hash 模式
const router = new VueRouter({
mode: 'hash',
routes: [
{ path: '/', component: Home },
{ path: '/about', component: About }
]
});
// 解释说明:
// 1. history 模式下,URL 不会带有 # 号,看起来更美观,但需要服务器配置支持。
// 2. hash 模式下,URL 会带有 # 号,例如 http://example.com/#/about,不需要服务器配置支持,兼容性更好。
上一篇:vue3使用watch
下一篇:vue 修饰符
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站