網(wǎng)站首頁 編程語言 正文
目錄
- uni-app之項目 首頁實現(xiàn)2
- 輪播圖的實現(xiàn)
- 首頁 導(dǎo)航的實現(xiàn)
- 推薦商品
- 完整的首頁
uni-app之項目 首頁實現(xiàn)2
輪播圖的實現(xiàn)
- 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: {
// 獲取了輪播圖數(shù)據(jù)
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>
- 效果
首頁 導(dǎo)航的實現(xiàn)
<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: {
// 獲取了輪播圖數(shù)據(jù)
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
相關(guān)推薦
- 2022-09-28 Windows?批處理cmd/bat常用命令詳解_DOS/BAT
- 2022-09-22 Python 短路運算符
- 2022-04-05 easyswoole轉(zhuǎn)發(fā)報錯 writev() failed (104 nginx
- 2022-07-19 linux臨時修改網(wǎng)卡
- 2023-12-06 Access denied for user root @ localhost (using p
- 2022-02-14 Linux?sftp命令用法_Linux
- 2023-02-18 Flow轉(zhuǎn)LiveData數(shù)據(jù)丟失原理詳解_Android
- 2022-10-02 SQL堆疊注入簡介_MsSql
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支