網站首頁 編程語言 正文
目錄
- uni-app之項目 首頁實現2
- 輪播圖的實現
- 首頁 導航的實現
- 推薦商品
- 完整的首頁
uni-app之項目 首頁實現2
輪播圖的實現
- index / index.vue
<template>
<view class="home">
首頁
swiper- {{ swiper }}
<swiper class="swiper" circular indicator-dots="true" autoplay interval="2000" duration="500" >
<swiper-item v-for="(item,idx) in swiper" :key="idx">
<view class="swiper-item uni-bg-red">{{item.title}}</view>
</swiper-item>
</swiper>
</view>
</template>
<script>
export default {
data() {
return {
swiper:[],
}
},
onLoad() {
this.getSwiper()
},
methods: {
// 獲取了輪播圖數據
async getSwiper(){
const res = await this.$myHttp({
url:"/swiper",
})
console.log("res",res);
this.swiper = res.data;
}
}
}
</script>
<style lang="scss">
.home {
.swiper {
width: 750rpx;
height: 380rpx;
background: orange;
}
}
</style>
- 效果
首頁 導航的實現
<template>
<view class="home">
<view class="nav">
<view class="nav_item" v-for="item in navList">
{{ item }}
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
navList:[1,2,3,4]
}
},
onLoad() {
},
methods: {
}
}
</script>
<style lang="scss">
.home {
.nav {
margin-top: 15rpx;
display: flex;
justify-content: space-around;
align-items: center;
.nav_item {
height: 120rpx;
line-height: 120rpx;
width: 120rpx;
border: 1px solid #ccc;
text-align: center;
}
}
}
</style>
- 效果
推薦商品
<template>
<view class="home">
<view class="recommend">
<view class="recommend_title">
推薦商品
</view>
<view class="recommend_list">
<view class="recommend_list_item">
商品1
</view>
<view class="recommend_list_item">
商品2
</view>
<view class="recommend_list_item">
商品3
</view>
<view class="recommend_list_item">
商品4
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {
},
methods: {
}
}
</script>
<style lang="scss">
.home {
.recommend {
margin-top: 10rpx;
background: #eee;
overflow: hidden;
.recommend_title {
margin: 7rpx 0;
height: 80rpx;
line-height: 80rpx;
color: $shop_color;
text-align: center;
background: #fff;
letter-spacing: 20rpx;
}
.recommend_list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 0 15rpx;
.recommend_list_item {
box-sizing: border-box;
margin-bottom: 15rpx;
background: #fff;
width: 355rpx;
height: 400rpx;
line-height: 400rpx;
text-align: center;
}
}
}
}
</style>
- 效果
完整的首頁
<template>
<view class="home">
<swiper class="swiper" circular indicator-dots="true" autoplay interval="2000" duration="500" >
<swiper-item v-for="(item,idx) in swiper" :key="idx">
<view class="swiper-item uni-bg-red">{{item.title}}</view>
</swiper-item>
</swiper>
<view class="nav">
<view class="nav_item" v-for="item in navList">
{{ item }}
</view>
</view>
<view class="recommend">
<view class="recommend_title">
推薦商品
</view>
<view class="recommend_list">
<view class="recommend_list_item" v-for="item in shopList">
{{ item.title}}
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
swiper:[],
navList:[1,2,3,4],
shopList:[],
}
},
onLoad() {
this.getSwiper();
this.getShopList();
},
methods: {
// 獲取了輪播圖數據
async getSwiper(){
const res = await this.$myHttp({
url:"/swiper",
})
console.log("res",res);
this.swiper = res.data;
},
// 獲取商品列表
async getShopList(){
const res = await this.$myHttp({
url:"/shopList",
})
this.shopList = res.data;
}
}
}
</script>
<style lang="scss">
.home {
.swiper {
width: 750rpx;
height: 380rpx;
background: orange;
}
.nav {
margin-top: 15rpx;
display: flex;
justify-content: space-around;
align-items: center;
.nav_item {
height: 120rpx;
line-height: 120rpx;
width: 120rpx;
border: 1px solid #ccc;
text-align: center;
color: $shop_color;
}
}
.recommend {
margin-top: 10rpx;
background: #eee;
overflow: hidden;
.recommend_title {
margin: 7rpx 0;
height: 80rpx;
line-height: 80rpx;
color: $shop_color;
text-align: center;
background: #fff;
letter-spacing: 20rpx;
}
.recommend_list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 0 15rpx;
.recommend_list_item {
box-sizing: border-box;
margin-bottom: 15rpx;
background: #fff;
width: 355rpx;
height: 400rpx;
line-height: 400rpx;
text-align: center;
}
}
}
}
</style>
原文鏈接:https://blog.csdn.net/weixin_43845137/article/details/124283424
相關推薦
- 2022-07-07 Python?pluggy框架使用示例代碼_python
- 2022-10-06 C#中List<T>存放元素的工作機制_C#教程
- 2022-05-04 詳解python的異常捕獲_python
- 2022-05-31 C語言可變參數與函數參數的內存對齊詳解_C 語言
- 2022-11-09 PostgreSQL?HOT與PHOT有哪些區別_PostgreSQL
- 2023-03-11 C/C++?-?從代碼到可執行程序的過程詳解_C 語言
- 2022-08-18 Git多人協同開發緊急修復線上bug操作指南_相關技巧
- 2022-06-01 Apache?Hudi靈活的Payload機制硬核解析_服務器其它
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支