K
K
Konstantin Malyarov2020-07-05 18:57:13
Vue.js
Konstantin Malyarov, 2020-07-05 18:57:13

Why doesn't vue see routes?

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')


Writes an error in the browser console.

[vue-router] Route with name 'index' does not exist
[vue-router] Route with name 'cart' does not exist

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-07-05
@Konstantin18ko

routers: [

The words "router" and "route" are not the same thing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question