我准备写个在移动端调试的demo,分头部,内容和底部,底部有三个菜单,公共的头部和底部放在components文件夹中,其他页面组件放在pages文件夹中;现在问题是组件中的文字不显示(只有首页显示):
猜测是哪里的路径写错了,但是又找不到,求助;
我的router/index.js文件如下:
import Vue from 'vue'
import Router from 'vue-router'
import Indexs from '../pages/index'
import Content from '../pages/content'
import Mine from '../pages/mine'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
name: 'index',
component: Indexs
},
{
path: '../pages/content',
name: 'content',
component: Content
},
{
path: '../pages/mine',
name: 'mine',
component: Mine
}
]
})
components/footer.vue文件:
<template>
<div class="footer">
<a @click="changeTab(index)" :key="index" v-for="(tab, index) in tabs">{{ tab.title }}</a>
</div>
</template>
<script>
export default {
name: 'footers',
data () {
return {
tabs: [
{
title: '首页',
path: '/'
},
{
title: '内容',
path: '../pages/content'
},
{
title: '我的',
path: '../pages/mine'
}
]
}
},
methods: {
changeTab (index) {
this.$router.push({path:this.tabs[index].path});
}
}
}
</script>
<style scoped>
.footer{
height: 50px;
width: 100%;
line-height: 50px;
position: fixed;
bottom: 0;
background-color: #999;
color: #fff;
text-align: center;
}
.footer a {
display: inline-block;
width: 33%;
}
</style>
router/index.js文件下的path路径指的是路由路径,你改为/pages/mine试试