feat(home): 更新页面标题并优化组件结构,修改数据方式为注入,完成“最受欢迎的电影”

- 将页面标题从"狗眼电影"更改为"狗尾电影"
- 在 MyMain 组件中引入 MostPopular 和 MovieList 子组件
- 为主内容区添加滚动条隐藏样式及背景色
- 修改 home 页面根元素标签并增加 provide 数据注入占位符
This commit is contained in:
2025-11-05 00:25:30 +08:00
parent e116ad351c
commit bd12e4998b
8 changed files with 136 additions and 6 deletions

View File

@@ -5,7 +5,7 @@
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>电影</title>
<title>电影</title>
</head>
<body>

BIN
src/assets/img/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -40,7 +40,7 @@ footer {
display: flex;
justify-content: space-between;
align-items: center;
border-top: 1px solid @border-color;
border-top: .5px solid @border-color;
>.item {
width: 90px;

View File

@@ -5,7 +5,6 @@
<span class="iconfont icon-caidan menu"></span>
</h1>
</header>
</template>
<script>

View File

@@ -1,15 +1,35 @@
<template>
<main class="main">
<!-- 所需数据转为依赖注入 -->
<Most-Popular />
<Movie-List />
</main>
</template>
<script>
import MostPopular from "@/pages/home/components/MyMostPopular.vue"
import MovieList from "@/pages/home/components/MyMovieList.vue"
export default {
components: {
MostPopular,
MovieList
},
data() {
return {
}
}
}
</script>
<style lang="less" scoped>
.main {
flex: 1;
overflow: auto;
background-color: @background-color;
//隐藏滚动条
&::-webkit-scrollbar {
display: none;
}
}
</style>

View File

@@ -0,0 +1,86 @@
<template>
<div class="mostpopular">
<p class="title">最受好评电影</p>
<ul>
<li class="movie" v-for="movie in data">
<a href="#">
<img :src="movie.img" alt="">
<h5>{{ movie.name }}</h5>
</a>
</li>
</ul>
</div>
</template>
<script>
export default {
inject: {
data: {
from: "mostpopular",
default: [{ name: "啥也没有", img: "src/assets/img/1.png" },
{ name: "啥也没有", img: "src/assets/img/1.png" },
{ name: "啥也没有", img: "src/assets/img/1.png" },
{ name: "啥也没有", img: "src/assets/img/1.png" },
{ name: "啥也没有", img: "src/assets/img/1.png" },
{ name: "啥也没有", img: "src/assets/img/1.png" },
{ name: "啥也没有", img: "src/assets/img/1.png" },
{ name: "啥也没有", img: "src/assets/img/1.png" },
{ name: "啥也没有", img: "src/assets/img/1.png" },
{ name: "啥也没有", img: "src/assets/img/1.png" }]
}
}
}
</script>
<style lang="less" scoped>
.mostpopular {
padding: 12px 15px;
margin-bottom: 10px;
background-color: white !important;
>.title {
font-size: @sfont;
color: #333;
margin-bottom: 12px;
}
>ul {
display: flex;
flex-wrap: nowrap;
overflow: auto;
&::-webkit-scrollbar {
display: none;
}
>li {
width: 85px;
min-height: 143px;
margin-right: 10px;
flex-shrink: 0;
>a {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
>img {
width: 100%;
height: 115px;
}
>h5 {
font-size: @ssfont;
color: #222;
margin-bottom: 2px;
font-weight: 600;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,18 @@
<template>
<div class="movielist">
</div>
</template>
<script>
export default {
}
</script>
<style lang="less">
.movielist {
width: 100%;
min-height: 200px;
background-color: white;
}
</style>

View File

@@ -1,10 +1,10 @@
<template>
<home class="home">
<Headera>电影</Headera>
<div class="home">
<Headera>电影</Headera>
<Nav />
<Main />
<Footer />
</home>
</div>
</template>
<script>
@@ -18,6 +18,13 @@ export default {
Nav,
Main,
Footer
}, provide() {
return {
// 最受好评的电影数据依赖
// mostpopular: "",
// 电影列表数据依赖
// movelist;""
}
}
}
</script>