Vue中抽取的footer组件,可复用
<template>
<div class="app-foot">
{{footerMsgCopyright}}
<span class="source">{{footerMsgName}}</span>
</div>
</template>
<script>
export default {
name: 'AppFoot',
data() {
return {
// 版权说明的文字
footerMsgCopyright: 'Copyright © 2020-2021 xxxx平台 - Powered By ',
// 单位
footerMsgName: 'xxxx实验室'
}
}
}
</script>
<style scoped>
.app-foot {
/* footer 固定在页面底部 */
min-height: 35px;
background-color: #eeeeee;
width: 100%;
font-size: 14px;
display: flex;
align-items: center;
justify-content: center;
}
.source{
font-weight: 600;
}
</style>
复用时直接调用组件
主页面设定高度时,要把footer的高度空出来,其style可以如下:
<style>
.main-container{
/* 35 = footer */
min-height: calc(100vh - 35px);
}
</style>
本文介绍如何在Vue中创建一个可复用的footer组件,详细阐述了组件的抽取和复用方法,并提供了在主页面设置样式以适应footer的示例。
702

被折叠的 条评论
为什么被折叠?



