router-view不生效的原因解釋


const routers= [
  {
    path:'/',
    name:'F',
    component:FP
  },
  {
    path:'/secondpage',
    component:()=>import('../views/secondpage.vue')
  },
  {
    path:'/thirdpage',
    component:()=>import('../views/thirdpage.vue')
  }
]
//錯誤的寫法
const router = new VueRouter({
 routers //原因
})

const routers = [
  {
    path:'/',
    name:'F',
    component:FP
  },
  {
    path:'/secondpage',
    component:()=>import('../views/secondpage.vue')
  },
  {
    path:'/thirdpage',
    component:()=>import('../views/thirdpage.vue')
  }
]
//正確的寫法
const router = new VueRouter({
  routes:routers //原因
})

這是vue-router里面的集合配置,其中new VueRouter({})中要給routes賦值,不是給routers賦值
ES6的簡寫用慣了就出事了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM