router-view 無效 組件不跳轉


最近做一個項目 設置好路由以后組件就是不跳轉而且不報錯 結果找了好半天
最后發現是VueRouter的routes屬性被我敲成了 routers

// 錯誤代碼
const router = new VueRouter({
  mode: 'history',
  routers
})


// 改正后
const router = new VueRouter({
  mode: 'history',
  routes
})

容器頁面部分

 <template>
  <div >
     <v-header></v-header>

     <div class="tab">
       <router-link class="tab-item" to='goods'>商品</router-link>
       <router-link class="tab-item" to='ratings'>評論</router-link>
       <router-link class="tab-item" to='sell'>商家</router-link>
     </div>

     <div class="content">
       <router-view></router-view>
     </div>
  </div>
</template>
<script>
  import header from './components/header/header.vue'

  export default {
      components: {
          'v-header': header
      }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">

    .tab
        display:flex
        width: 100%
        height: 40px;
        line-height: 40px;
        .tab-item
           flex:1
           text-align: center

</style>






免責聲明!

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



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