当前位置: 首页 > news >正文

Vue全栈开发旅游网项目首页

0. 展示效果:

书接上回:

https://blog.csdn.net/Tttian622/article/details/143212387?spm=1001.2014.3001.5502

1.“热门推荐”模块的制作:

位置:src\components\home\Hot.vue

1.1 <script> 模块

列举各个景点信息

<script setup>
import { ref } from 'vue';
const hotList = ref([{ id: 1, img: '/static/home/hot/h1.jpg', name: '景点名称', price: 65 },{ id: 2, img: '/static/home/hot/h2.jpg', name: '景点名称', price: 65 },{ id: 3, img: '/static/home/hot/h3.jpg', name: '景点名称', price: 65 },{ id: 4, img: '/static/home/hot/h4.jpg', name: '景点名称', price: 65 },{ id: 5, img: '/static/home/hot/h5.jpg', name: '景点名称', price: 65 },{ id: 6, img: '/static/home/hot/h6.jpg', name: '景点名称', price: 65 },{ id: 7, img: '/static/home/hot/h7.jpg', name: '景点名称', price: 65 },{ id: 8, img: '/static/home/hot/h8.jpg', name: '景点名称', price: 65 },{ id: 9, img: '/static/home/hot/h9.jpg', name: '景点名称', price: 65 },{ id: 10, img: '/static/home/hot/h10.jpg', name: '景点名称', price: 65 }
])
</script>

1.2 <template> 模块

其中RouterLink相当于a超链接,通过该标记,可访问路由列表,

最后根据地址访问目标。

<template><!-- 热门经典 --><div class="home-hot-box"><!-- 顶上导航 --><van-cell title="热门推荐" is-link value="全部榜单" icon="/static/home/hot/fire.png" title-style="text-align:left" /><!-- 经典列表 --><div class="box-main"><RouterLink class="hot-item" v-for="item in hotList" :key="item.id" :to="`#`"><div class="img"><span class="span"></span><img :src="item.img" alt=""></div><h5 class="van-ellipsis">{{ item.name }}</h5><div class="line-price"><span class="price">¥{{ item.price }}</span>起</div></RouterLink></div></div>
</template>

1.3 <style> 模块

padding: 0 10px;  //内边距:上下0px  左右10px

margin-right: 10px;  //外边距

display: flex;  //弹性布局

overflow: scroll; //无论内容是否溢出,元素都会提供滚动条。

flex-direction: column;

//flex-direction:决定弹性布局的方向(主轴方向),默认横向

//column:主轴为垂直方向,起点在上沿

position: relative;  //相对定位

position: absolute;  //绝对定位

no-repeat;  //不平铺

<style lang="less">
.home-hot-box {padding: 0 10px;//设置顶上导航样式.van-cell {padding: 10px 0px;}// 经典列表样式.box-main {width: 100%;display: flex;padding-top: 10px;overflow: scroll;}//热门元素.hot-item {display: flex;flex-direction: column;width: 100px;margin-right: 10px;padding-bottom: 10px;//图片样式.img {position: relative;.span {position: absolute;left: 0;top: 0;display: inline-block;width: 42px;height: 20px;z-index: 10;}img {width: 100px;height: 100px;}}h5 {color: #212121;padding: 2px 0;font-size: 12px;margin: 0px;}.line-price {color: #212121;font-size: 12px;.price {color: orange;font-size: 13px;}}//当前所有元素节点&:nth-child(1) .img span {background: url(/static/home/hot/top1.png)no-repeat;background-size: 100% auto;}&:nth-child(2) .img span {background: url(/static/home/hot/top2.png)no-repeat; background-size: 100% auto;}&:nth-child(3) .img span {background: url(/static/home/hot/top3.png)no-repeat; background-size: 100% auto;}}
}
</style>

1.4 主页面homeView.vue

<script setup>
import Hot from '@/components/home/Hot.vue';
</script>
<template><!-- 热门推荐   --><Hot />
</template>

2. “精选景点”模块的制作:

2.1 <script> 模块

<script setup>
import { ref } from 'vue';
const fineList = ref([{ id: 1, name: '景点名称', score: 5, price: 98 },{ id: 2, name: '景点名称', score: 4.5, price: 98 },{ id: 3, name: '景点名称', score: 4, price: 98 },{ id: 4, name: '景点名称', score: 4.5, price: 98 },{ id: 5, name: '景点名称', score: 4.5, price: 98 },{ id: 6, name: '景点名称', score: 5, price: 98 }
])
</script>

2.2 <template> 模块

<template><!-- 精选经典 --><div class="home-fine-box"><!-- 顶上导航 --><van-cell title="精选景点" is-link value="更多" icon="location-o" title-style="text-align:left" /><!-- 景点列表 --><div class="box-main"><a href="#" class="sight-item" v-for="item in fineList" :key="item.id"><img src="/static/home/hot/h1.jpg" alt=""><div class="right"><h5>{{ item.name }}</h5><van-rate v-model="item.score" readonly=""/><div class="tips">4人点评|100%满意</div><div class="tips" light>辽宁-沈阳</div><div class="line-price">¥{{ item.price }}</div></div></a></div></div>
</template>

2.3 <style> 模块

border-bottom: 1px solid #f6f6f6;  

//给下边框(border-bottom)一个粗细为1px的浅灰色(#f6f6f6)实线(solid

text-align: left;  //文本内容居左

flex-grow: 1;  //布局填充,默认值为0:保留原大小,1:扩大填充

justify-content: left;  //非文本(例如:⭐)居左

<style lang="less">
.home-fine-box {padding: 0 10px;.van-cell {padding: 10px 0px;}//景点列表.box-main {.sight-item {display: flex;margin-top: 10px;border-bottom: 1px solid #f6f6f6;img {width: 100px;height: 100px;}.right {text-align: left; flex-grow: 1;justify-content: left;padding-left: 5px;position: relative;h5 {color: #212121;font-size: 14px;padding: 5px 0;margin: 0px;}.line-price {color: orange;font-size: 16px;position: absolute;right: 10px;top: 20px;display: inline-block;font-weight: bold;}.tips {font-size: 12px;color: #666;&.light {color: #999;}}}}}
}</style>

2.4 主页面homeView.vue

<script setup>
import Fine from '@/components/home/Fine.vue';
</script>
<template><!-- 精选景点 --><Fine style="margin-bottom: 10px;"></Fine>
</template>

3. 设置全局组件

由于精选景点(为例)模块信息,会在其他位置用到,

所以将其中数据,如图片、地区、价格等设置成全局组件。

方便随时提用:

3.1 新建ListSight.vue

src/components/common/ListSight.vue

3.2 搬运(ListSight.vue)

从Fine.vue中搬运信息,到ListSight.vue中来:

<script>
export default{props:['item']
}
</script><template><a href="#" class="sight-item"><img src="/static/home/hot/h1.jpg" alt=""><div class="right"><h5>{{ item.name }}</h5><van-rate v-model="item.score" readonly="" /><div class="tips">4人点评|100%满意</div><div class="tips" light>辽宁-沈阳</div><div class="line-price">¥{{ item.price }}</div></div></a>
</template><style lang="less">
.sight-item {display: flex;margin-top: 10px;border-bottom: 1px solid #f6f6f6; //下边框img {width: 100px;height: 100px;}.right {text-align: left; //文本内容居左flex-grow: 1; //布局填充,默认值为0:保留原大小,1:扩大填充justify-content: left; //非文本(⭐)居左padding-left: 5px;position: relative;h5 {color: #212121;font-size: 14px;padding: 5px 0;margin: 0px;}.line-price {color: orange;font-size: 16px;position: absolute;right: 10px;top: 20px;display: inline-block;font-weight: bold;}.tips {font-size: 12px;color: #666;&.light {color: #999;}}}
}
</style>

3.3 现·Fine.vue

<script setup>
import ListSight from '../common/ListSight.vue';
import { ref } from 'vue';
const fineList = ref([{ id: 1, name: '景点名称', score: 5, price: 98 },{ id: 2, name: '景点名称', score: 4.5, price: 98 },{ id: 3, name: '景点名称', score: 4, price: 98 },{ id: 4, name: '景点名称', score: 4.5, price: 98 },{ id: 5, name: '景点名称', score: 4.5, price: 98 },{ id: 6, name: '景点名称', score: 5, price: 98 }
])
</script><template><!-- 精选经典 --><div class="home-fine-box"><!-- 顶上导航 --><van-cell title="精选景点" is-link value="更多" icon="location-o" title-style="text-align:left" /><!-- 景点列表 --><div class="box-main"><ListSight v-for="item in fineList" :key="item.id" :item="item"/></div></div>
</template><style lang="less">
.home-fine-box {padding: 0 10px;.van-cell {padding: 10px 0px;}//景点列表// .box-main {// }
}
</style>

4.页脚·脚部分

4.1 Footer.vue:

<script setup>
import { ref } from 'vue';
const active =ref()
</script><template><div><van-tabbar v-model="active"><van-tabbar-item icon="wap-home-o" name="home">首页</van-tabbar-item><van-tabbar-item icon="search" name="search">搜索</van-tabbar-item><van-tabbar-item icon="user-o" name="mine">我</van-tabbar-item></van-tabbar></div>
</template>

4.2 主页面homeView.vue

<script setup>
import TripFooter from '@/components/common/Footer.vue';
</script>
<template><!-- 底部导航 --><TripFooter />
</template>


http://www.mrgr.cn/news/59358.html

相关文章:

  • 论1+2+3+4+... = -1/12 的不同算法
  • 通过HBase实现大规模日志数据存储与分析
  • github上传文件代码以及其它github代码
  • 2024年MathorCup妈杯大数据竞赛选题人数发布
  • MATLAB深度学习杂草识别系统
  • Python | Leetcode Python题解之第513题找树左下角的值
  • C++,STL 048(24.10.25)
  • XCode16中c++头文件找不到解决办法
  • SQLI LABS | Less-12 POST-Error Based-Double quotes-String-with twist
  • 第二十六节 直方图均衡化
  • S-Function
  • Python | Leetcode Python题解之第514题自由之路
  • Leetcode刷题笔记13
  • 安全日志里提示:C:\Windows\System32\dasHost.exe
  • mysql5.7.44 arm 源码编译安装
  • Linux常用命令1
  • python源码编译—Cython隐藏源码(windows)
  • [dasctf]howtodecompile
  • xlnt加载excel报错:‘localSheetId‘ expected
  • 【Spring】控制反转 依赖注入(本文内容由大模型生成)