赞
踩
vue 2的项目安装vue-router使用的版本应该为 3
npm i vue-router@3
import VueRouter from "vue-router"; //引入路由组件 import Home from "@/pages/Home" import Search from "@/pages/Search" import Register from "@/pages/Register" import Login from "@/pages/Login" export default new VueRouter({ routes:[ { path:'/Home', component:Home }, ] })
Vue.use(VueRouter)应该写在main.js中
import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
Vue.config.productionTip = false
import router from './router'
new Vue({
render: h => h(App),
//注册路由
router
}).$mount('#app')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。