最近做一個項目 設置好路由以后組件就是不跳轉而且不報錯 結果找了好半天
最后發現是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>