zoukankan      html  css  js  c++  java
  • Cannot read property 'matched' of undefined"

    错误代码 D:workspacexxxsrcmain.js

    const routes = new VueRouter({
      routes: [
        {
          path: '/apple',
          component: Apple
        },
        {
          path: '/banana',
          component: Banana
        }
      ]
    })
    /* eslint-disable no-new */
    new Vue({
      el: '#app',
      routes,
      template: '<App/>',
      components: { App }
    })
    

      

    正确代码1

    const router = new VueRouter({
      routes: [
        {
          path: '/apple',
          component: Apple
        },
        {
          path: '/banana',
          component: Banana
        }
      ]
    })
    /* eslint-disable no-new */
    new Vue({
      el: '#app',
      router,
      template: '<App/>',
      components: { App }
    })
    

      

    正确代码2

    const routes = new VueRouter({
      routes: [
        {
          path: '/apple',
          component: Apple
        },
        {
          path: '/banana',
          component: Banana
        }
      ]
    })
    /* eslint-disable no-new */
    new Vue({
      el: '#app',
      router: routes,
      template: '<App/>',
      components: { App }
    })
    

      

    错误分析: router才是合法参数,缩写的时候要注意。

      




    另外 path: './apple',  应该是path: '/apple'

    const routes = new VRouter({
      routes: [
        {
          path: './apple',
          component: Apple
        },
        {
          path: './banana',
          component: Banana
        }
      ]
    })
    

      

  • 相关阅读:
    11.MySQL
    10、设计模式
    9
    8
    7
    6
    5
    4
    3
    2
  • 原文地址:https://www.cnblogs.com/tabCtrlShift/p/9162510.html
Copyright © 2011-2022 走看看