【问题标题】:Vue js, footer not displayingVue js,页脚不显示
【发布时间】:2018-04-06 10:19:48
【问题描述】:

我已经安装了 vue cli,当我尝试显示我的导航栏(组件)时它会显示,但是当我尝试显示我的页脚(组件)时它会显示。 当我显示其他 cms 页面时,导航栏和页脚在一起,文本不会显示在... 找到图像,输出: 这是我的导航栏,它是组件文件夹下的一个组件

<template>
        <div>
            <ul class="navbar-nav">
                <li class="nav-item">
                    <router-link to="/" class="nav-link">Home</router-link>
                </li>
                <li class="nav-item">
                    <router-link to="/contacts" class="nav-link">Contacts Us</router-link>
                </li>
                <li class="nav-item">
                    <router-link to="/login" class="nav-link">Login</router-link>
                </li>
            </ul>
        </div>
</template>
<script>
   export default {
      name: 'Navbar'
    }
</script>

这是我的主页,它是组件文件夹下的一个组件

<template>
    <div>
        test
    </div>
</template>
<script>
    export default {
    name: 'HomePage'
    }
</script>

这是 App.vue 里面的 Src/ 文件夹

<template>
  <div id="app">
    <app-header></app-header>
    <app-footer></app-footer>
        <router-view></router-view>
  </div>
</template>

<script>
import Navbar from '@/components/Navbar'
import Footer from '@/components/Footer'
export default {
  name: 'App',
  components: {
    'app-header': Navbar,
     'app-footer' : Footer
  }
}
</script>

这是页脚组件

<template>
  <div class="hello">
    <footer class="text-muted">
      <div class="container">
        <p class="float-right">
          <a href="#">Back to top</a>
        </p>
        <p>Album example is © Bootstrap, but please download and customize it for yourself!</p>
        <p>New to Bootstrap? <a href="../../">Visit the homepage</a> or read our <a href="../../getting-started/">getting started guide</a>.</p>
      </div>
    </footer>
  </div>
</template>

<script>
export default {
  name: 'Footer',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  }
}
</script>

【问题讨论】:

  • 页脚组件的代码在哪里?
  • 现在检查我已经添加了
  • 你有什么错误吗?
  • 不,我没有收到任何错误,请稍等一下提供屏幕截图
  • 你确定 css 加载正确吗?

标签: vue.js vue-component


【解决方案1】:

在您的 App.vue 模板中,您的元素顺序错误。

&lt;app-footer&gt;移动到&lt;router-view&gt;下方:

<template>
  <div id="app">
    <app-header></app-header>

    <router-view></router-view>

    <app-footer></app-footer>
  </div>
</template

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-19
    • 2019-01-09
    • 2019-01-17
    • 2018-06-29
    • 2019-05-16
    • 2021-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多