vue组件的内容不显示

我准备写个在移动端调试的demo,分头部,内容和底部,底部有三个菜单,公共的头部和底部放在components文件夹中,其他页面组件放在pages文件夹中;现在问题是组件中的文字不显示(只有首页显示):

clipboard.png
猜测是哪里的路径写错了,但是又找不到,求助;

clipboard.png

clipboard.png

我的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>
  
阅读 13.1k
1 个回答

router/index.js文件下的path路径指的是路由路径,你改为/pages/mine试试

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题