Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

vue history和hash区别

作者:霸气邪剑仙   发布日期:2025-06-25   浏览:23

// 使用 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 修饰符

大家都在看

vue.config.js configu

node.js vue

vue查看版本

vue等待几秒

vue3 setup computed

vue screenfull

vue json.stringify

vue 遍历list

typescript vue

vue 复选框

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站