报错:
Cannot read properties of undefined (reading 'use') //翻译:无法读取未定义的属性(读取“使用”) //就是use方法未被调用
就是配置好路由但是路由不加载
router.js配置如下
import Vue from 'vue' import VueRouter from 'vue-router' Vue.use(VueRouter) import Home from './components/HelloWorld.vue' var router = new VueRouter({ // 创建路由实例对象router routes: [ { path: '/', redirect: '/home' }, { path: '/home', component: Home, name: 'home' } ] }) export default router // 暴露路由对象属性
main.js配置如下
import Vue from 'vue' import App from './App.vue' import router from './router.js' Vue.config.productionTip = false new Vue({ router, render: h => h(App), }).$mount('#app')