目录
1.创建首页并成功运行[{插入main icon },{搜索框(虽然还没做搜索功能)},{ 超链接(这个可以用(/doge)},{导航栏(没做功能)},{轮播图(比例有点大)}]
4.优化方向:1.节省style的调整时间 2.分文件书写 3.调整图片比例 4.记得写注释 5.不要忘记写方法了!!!
今日进度记录
1.创建首页并成功运行
[{插入main icon },{搜索框(虽然还没做搜索功能)},{ 超链接(这个可以用(/doge)},{导航栏(没做功能)},{轮播图(比例有点大)}]
2.在App.vue内相关代码
<template>
<div class="home">
<el-container>
<el-header class="flex-container">
<!--main icon -->
<el-image src="src\assests\image\main icon.png" fit="contain" @click="goToHome" class="custom-image"></el-image>
<!--search start-->
<el-input placeholder="请输入关键字搜索..." v-model="search" class="custom-input"></el-input>
<!--search end-->
<!--link start-->
<div class="links-container">
<el-link type="primary" href="https://www.zcst.edu.cn/">学校官网</el-link>
<span>|</span>
<el-link type="primary" href="https://library.jluzh.edu.cn/">图书馆</el-link>
<span>|</span>
<el-link type="primary" href="https://vpn.zcst.edu.cn/webvpn/LjE1NC4yMTcuMTcwLjE2OC4xNjg=/LjE2NS4yMTIuMTY5LjEwMi4xNzUuMTUzLjE2My4xNzIuOTguMTk4LjIwMi4yMTUuOTguMTQ3LjE1OA==/login?vpn-0&service=https:%2F%2Fvpn.zcst.edu.cn%2Frump_frontend%2FloginFromCas%2F">校内资源访问</el-link>
</div>
<!--link end-->
<!--导航栏 start-->
</el-header>
<el-container>
<el-header class="header">
<el-menu :default-active="activeIndex" class="centered-menu" justify="true" @select="handleSelect" mode="horizontal">
<el-menu-item index="1">首页</el-menu-item>
<el-menu-item index="2">学院概况</el-menu-item>
<el-menu-item index="3">学院要闻</el-menu-item>
<el-menu-item index="4">学历与能力提升</el-menu-item>
<el-menu-item index="5">资格证书</el-menu-item>
<el-menu-item index="6">国际教育</el-menu-item>
<el-menu-item index="7">企事业培训</el-menu-item>
<el-menu-item index="8">联系我们</el-menu-item>
</el-menu>
</el-header>
<!--导航栏 end-->
<!--轮播图 start-->
<el-main>
<el-carousel trigger="click" width="750px" height="900px">
<el-carousel-item v-for="(itemUrl, index) in carouselItems" :key="index">
<img :src="itemUrl" class="carousel-image" alt="Carousel Image">
</el-carousel-item>
</el-carousel>
</el-main>
<!--轮播图 end-->
</el-container>
</el-container>
</div>
</template>
<script setup>
import { ref, reactive, toRefs } from 'vue';
import { useRouter } from 'vue-router';
const search = ref('');
const activeIndex = ref('1');
const carouselItems = reactive([
'src/assests/image/图书馆正02.jpeg',
'src/assests/image/图书馆正01.jpeg',
'src/assests/image/地球仪.jpeg',
'src/assests/image/图书馆02.jpeg'
]);
const router = useRouter();
const goToHome = () => {
router.push('/');
};
const handleSelect = (key) => {
activeIndex.value = key;
};
defineExpose({
...toRefs({ search, activeIndex, carouselItems }),
goToHome,
handleSelect
});
</script>
<style scoped>
.custom-image { /*main icon */
margin-right: 100px;
width: 450px; /* 宽度 */
height: 75px;/* 长度 */
object-fit: contain;
}
.custom-input { /*search*/
width: 100%;
height: 40px;
flex: 1;
}
.links-container { /* 超链接容器 */
display: flex; /* 设置为弹性容器 */
align-items: center; /* 垂直居中对齐 */
}
.links-container .el-link { /*超链接*/
color:darkgrey !important;
display: inline-flex;
align-items: center;
margin: 0 0 0 8px;
}
.links-container span {
margin: 0 5px;
}
.header{/*导航栏平均分布并居中 */
height: 60px;
line-height: 60px;
}
.centered-menu { /*导航栏背景 */
background-color:brown;
display: flex;
justify-content: center;
align-items: center;
}
.centered-menu .el-menu-item { /*导航栏背景 */
color:whitesmoke;
}
.flex-container { /*导航栏和轮播图分开放置 */
display: flex;
justify-content: space-between;
align-items:center;
}
</style>
3.提出问题:1.这些代码是可以直接写到App.vue中吗?还是要分开写?2.如果要分开写我应该怎么写?目前只会写到一起(sad)3.之前是将这些代码写到views/Home.vue里的时候为什么展示不了(但是在vue的devtools里面显示了)
4.优化方向:1.节省style的调整时间 2.分文件书写 3.调整图片比例 4.记得写注释 5.不要忘记写方法了!!!
惨痛教训:别乱删路径,直接运行不了(苦笑)