你的位置:首页 > 信息动态 > 新闻中心
信息动态
联系我们

【Vue3.0】报错 Object(...) is not a function,history: createWebHashHistory()

2021/12/17 16:05:12

引用hash模式运行项目报错,错误信息如下
在这里插入图片描述
在这里插入图片描述

import { createRouter, createWebHashHistory } from 'vue-router'
import routes from './routes'

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router

解决方法:升级 vue-router 版本

npm install vue-router --save
# + vue-router@3.5.2
 
# 升级修复
npm install vue-router@next
# + vue-router@4.0.10