src/router/router.js
import Vue from "vue";
import Router from "vue-router";
import index from '../page/index.vue'
import cart from '../page/cart.vue'
Vue.use(Router)
const router = new Router({
routers: [
{
path: '/',
name: 'index',
component: index
},
{
path: '/cart',
name: 'cart',
component: cart
},
]
})
export default router;
main.js
import Vue from 'vue'
import App from './App.vue'
import router from "./router/router";
import 'materialize-css/dist/css/materialize.min.css'
import 'material-design-icons/iconfont/material-icons.css'
Vue.config.productionTip = false
new Vue({
router,
render: h => h(App),
}).$mount('#app')
В консоли браузера пишет ошибку.
[vue-router] Route with name 'index' does not exist
[vue-router] Route with name 'cart' does not exist