需求:需要在底部做个固定样式,添加备案等信息
实现思路:
1. 定义文本,数组对象记录,循环遍历,有利于维护
2. 定义样式,固定定位 + 层级置顶
3. 抽离成组件复用
js
<script lang="ts" setup>
const bottomInfoList = [
{ label: '关于我们', link: 'user/aboutUs' },
{ label: '帮助与反馈', link: 'user/feedback' },
{ label: '主办单位:XXXX', link: '' },
{ label: 'ICP备案/许可证号:XXXX', link: 'https://baidu.com' },
]
</script>
css
<style scoped>
.bottominfo {
width: 100%;
height: 40px;
background-color: #f2f5f7;
position: fixed;
bottom: 0;
z-index: 100;
font-size: 12px;
line-height: 40px;
text-align: center;
a {
margin-left: 5px;
margin-right: 5px;
text-decoration: none;
color: #686c74;
}
}
</style>
template
<template>
<div class="bottominfo">
<a v-for="(item, index) in bottomInfoList" :key="`${index}`" :href="item.link">{{ item.label }}</a>
</div>
</template>
放在一个vue文件里,然后在需要的文件引用
<srcipt lang="ts" setup>
import Footer from '../components/home/footer.vue' // 路径
</script>
<template>
<!-- 引用 -->
<Footer />
</template>
标签:40px,封装,样式,text,label,link,5px,简单
From: https://blog.csdn.net/shadowflies/article/details/144704904