报'use' of undefined错

来源:12-1 Vue 3.0环境升级

qq_唯s彩_2

2021-05-26

import Vue from 'vue’
import Router from ‘vue-router’
//import Home from ‘…/pages/home/Home.vue’
//import City from ‘…/pages/city/City’
//import Detail from ‘…/pages/detail/Detail’
//Vue.use(Router)

Vue.use(Router)

export default new Router({

routes: [
{
path: ‘/’,
name: ‘Home’,
component: () => import(’…/pages/home/Home.vue’)
},
{
path: ‘/city’,
name: ‘City’,
component: () => import(’…/pages/city/City’)
},
{
path: ‘/Detail/:id’,
name: ‘Detail’,
component: () => import(’…/pages/detail/Detail’)
},
],

scrollBehavior (to ,from , savedPostition) {
return { x: 0 , y:0}
}
});

我复制了你线上的代码 还是会报 “Uncaught TypeError: Cannot read property ‘use’ of undefined” 的错

写回答

1回答

Dell

2021-05-26

看下你vue的版本是多少?

0
4
Dell
回复
qq_唯s彩_2
对比下我master分支的代码,你看我用的是use吗,应该vue 换了使用插件的语法,你把代码照着我的代码改一下即可。
2021-05-31
共4条回复

Vue2.5-2.6-3.0开发去哪儿网App 零基础入门到实战

课程紧跟Vue3版本迭代,企业主流版本Vue2+Vue3全掌握

10675 学习 · 8191 问题

查看课程