vue--history模式

查了官网才知道4.0版本跟以前不一样的设置。分两步
① 导入
createWebHistory最后的这个才是历史模式,中间的是hash模式

import {
    
     createRouter, createWebHashHistory , createWebHistory } from 'vue-router'

② 使用
history: createWebHistory(), //这才是使用history模式这句话才是重点

const router = createRouter({
    
    
  // history: createWebHashHistory(),
  history: createWebHistory(), //这才是使用history模式
  routes
})

猜你喜欢

转载自blog.csdn.net/weixin_44239550/article/details/128666192