我希望我可以导入这个Footer.vue组件,并在我的App. vue中全局使用它。如果您需要任何进一步的细节,请不要犹豫,问,真的很感激一些帮助,我是一个有点noob试图学习这个新的框架啊哈!
因此,我最初在./components/Footer. vue中创建了一个页脚组件。以下是该特定组件的代码**(页脚组件)**-
<template>
<section>
<div class="skew skew-top mr-for-radius">
<svg class="h-8 md:h-12 lg:h-20 w-full text-gray-900" viewbox="0 0 10 10" preserveaspectratio="none">
<polygon fill="currentColor" points="0 0 10 10 0 10"></polygon>
</svg>
</div>
<div class="skew skew-top ml-for-radius">
<svg class="h-8 md:h-12 lg:h-20 w-full text-gray-900" viewbox="0 0 10 10" preserveaspectratio="none">
<polygon fill="currentColor" points="0 10 10 0 10 10"></polygon>
</svg>
</div>
<div class="py-20 bg-gray-900 radius-for-skewed">
<div class="container mx-auto px-4">
<div class="flex flex-wrap">
<div class="w-full lg:w-1/3 mb-16 lg:mb-0">
<a class="inline-block mb-3 text-white text-3xl font-bold leading-none" href="#">
<img class="mb-3 h-12" src="atis-assets/logo/atis/atis-color-white.svg" alt="" width="auto">
</a>
<p class="mb-4 max-w-sm text-gray-400 leading-loose">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus tincidunt felis eu est.</p>
<div>
<a class="inline-block w-10 mr-2 p-2 bg-gray-800 hover:bg-gray-700 rounded" href="#">
<img class="mx-auto" src="atis-assets/social/facebook-purple.svg">
</a>
<a class="inline-block w-10 mr-2 p-2 bg-gray-800 hover:bg-gray-700 rounded" href="#">
<img class="mx-auto" src="atis-assets/social/twitter-purple.svg">
</a>
<a class="inline-block w-10 p-2 bg-gray-800 hover:bg-gray-700 rounded" href="#">
<img class="mx-auto" src="atis-assets/social/instagram-purple.svg">
</a>
</div>
</div>
<div class="w-full lg:w-2/3 lg:pl-16 flex flex-wrap justify-between">
<div class="w-full md:w-1/3 lg:w-auto mb-16 md:mb-0">
<h3 class="mb-6 text-2xl font-bold text-purple-600">Products</h3>
<ul>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">Services</a></li>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">About Us</a></li>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">News and Stories</a></li>
<li><a class="text-gray-400 hover:text-gray-300" href="#">Roadmap</a></li>
</ul>
</div>
<div class="w-full md:w-1/3 lg:w-auto mb-16 md:mb-0">
<h3 class="mb-6 text-2xl font-bold text-purple-600">Important Links</h3>
<ul>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">Organization Team</a></li>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">Our Journeys</a></li>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">Pricing Plans</a></li>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">Roadmap</a></li>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">Terms & Conditions</a></li>
<li><a class="text-gray-400 hover:text-gray-300" href="#">Privacy Policy</a></li>
</ul>
</div>
<div class="w-full md:w-1/3 lg:w-auto">
<h3 class="mb-6 text-2xl font-bold text-purple-600">Company</h3>
<ul>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">About Us</a></li>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">Jobs</a></li>
<li class="mb-4"><a class="text-gray-400 hover:text-gray-300" href="#">Press</a></li>
<li><a class="text-gray-400 hover:text-gray-300" href="#">Contact Us</a></li>
</ul>
</div>
</div>
</div>
<p class="lg:text-center text-sm text-gray-400 border-t border-gray-800 pt-12 mt-16">© 2021. All rights reserved.</p>
</div>
</div>
<div class="skew skew-bottom mr-for-radius">
<svg class="h-8 md:h-12 lg:h-20 w-full text-gray-900" viewbox="0 0 10 10" preserveaspectratio="none">
<polygon fill="currentColor" points="0 0 10 0 0 10"></polygon>
</svg>
</div>
<div class="skew skew-bottom ml-for-radius">
<svg class="h-8 md:h-12 lg:h-20 w-full text-gray-900" viewbox="0 0 10 10" preserveaspectratio="none">
<polygon fill="currentColor" points="0 0 10 0 10 10"></polygon>
</svg>
</div>
</section>
</template>
<script>
export default {}
</script>```
**And here is the contents of my App.vue -**
```<script>
import { createApp } from 'vue'
import Footer from './components/Footer.vue'
const globalComponents = createApp({})
globalComponents.component(
// the registered name
'Footer',
)
app
.component('Footer', Footer)
</script>
<template>
<h1 class="text-[100px] text-center m-auto text-red underline"> Hello Vue JS </h1>
</template>
<Footer />
<style scoped>
</style>```
However, when I run npm run dev everything opens and the local server but just shows a blank page, not even then <template><h1>Hello Vue JS</h1><template/>
Not only this but the footer doesnt appear at all and is highlighted grey in my IDE which is assume means its not being imported correctly.
I was expecting that I could import this Footer.vue component and use it as a globally in my App.vue. If you need any further details please dont hesitate to ask, would really appreciate some help, I'm a bit of a noob trying to learn this new framework ahah!**
1条答案
按热度按时间rekjcdws1#
将页脚放在
<template>
内代码在这里
我不认为你需要
createApp
只需将
<Footer />
放入App.vue
中的<templete>
标记内Hello World!是您的主要内容,页脚是您的页脚内容或面包屑内容
如果您有
Header.vue
,您可以使用相同的方法添加标题