uniapp实战仿写网易云音乐(一)—底部工具栏以及首页轮播图swiper的实现

前言

从本篇文章开始记录uniapp实战仿写网易云音乐项目的过程,主要会写一下关键步骤和难点,本专栏会保持持续更新,并在最后送上源码,感兴趣的可以订阅本专栏。本篇主要实现的是首页tab栏以及图片滚动区域。

首页导航栏

首先要在page.json中配置页面和导航栏:
pages页面,这里有五个页面

"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
	{
		"path": "pages/index/index",
		"style": {
			"navigationBarTitleText": "uni-app",
			"app-plus":{
				"titleNView": false
			}
		}
	},
	{
		"path": "pages/video/video",
		"style": {
			"navigationBarTitleText": "uni-app"
		}
	},
	{
		"path": "pages/mine/mine",
		"style": {
			"navigationBarTitleText": "uni-app"
		}
	}
    ,{
           "path" : "pages/account/account",
           "style" :                                                                                    
           {
               "navigationBarTitleText": "",
               "enablePullDownRefresh": false
           }
           
       }
       ,{
           "path" : "pages/cloud/cloud",
           "style" :                                                                                    
           {
               "navigationBarTitleText": "",
               "enablePullDownRefresh": false
           }
           
       }
   ],

tabBar配置导航栏,五个页面五个导航栏,注意这里每个导航栏都有未选中的图片和选中的图片:

"tabBar": {
		"color":"#888",
		"selectedColor":"#ff2419",
		"borderStyle":"white",
		"backgroundColor":"#f9f9f9",
		"list": [
			{
				"pagePath":"pages/index/index",
				"iconPath":"static/tab/t_1.png",
				"selectedIconPath":"static/tab/t_11.png",
				"text":"首页"
			},
			{
				"pagePath":"pages/video/video",
				"iconPath":"static/tab/t_2.png",
				"selectedIconPath":"static/tab/t_21.png",
				"text":"视频"
			},
			{
				"pagePath":"pages/mine/mine",
				"iconPath":"static/tab/t_3.png",
				"selectedIconPath":"static/tab/t_31.png",
				"text":"我的"
			},
			{
				"pagePath":"pages/cloud/cloud",
				"iconPath":"static/tab/t_4.png",
				"selectedIconPath":"static/tab/t_41.png",
				"text":"云村"
			},
			{
				"pagePath":"pages/account/account",
				"iconPath":"static/tab/t_5.png",
				"selectedIconPath":"static/tab/t_51.png",
				"text":"账号"
			}
		]
	}

公共样式的配置

一般在项目中都会配置一些公共样式,比如一些页面或者组件的样式,还有这里用到的iconfont样式
一般单独文件存放公共样式
在这里插入图片描述
然后在App.vue页面进行引入:

<style lang="scss">
	/*每个页面公共css */
	@import url("./common/css/common.scss");
	@import url("./common/css/iconfont.css");
</style>

另外我们还需要去掉uniapp的头部内容:
在这里插入图片描述
我们只需要在page.json中加上这块代码就行 ,关闭标题显示
在这里插入图片描述

首页轮播图

轮播图我们使用uniapp自带的swiper组件,详细用法可以参考官方文档 链接
我们首先先把需要轮播的图片数据获取到:

methods: {
	getBanner() {
		uni.request({
			url: 'http://localhost:3000/banner',
			method: 'GET',
			success:(res)=>{
				this.swiper = res.data.banners;
			}
		})
	}
}

然后编写轮播图

<!-- 轮播 -->
<view class="banner">
	<swiper :indicator-dots="true" 
	        :autoplay="true" 
			indicator-color="rgba(255,255,255, .5)"
			indicator-active-color="#ff372b"
			:interval="3000" 
			:duration="500">
		<swiper-item v-for="(item,index) in swiper" :key="index">
			<view class="item">
				<image :src="item.imageUrl" class="img"></image>
				<view class="tag">
					{{item.typeTitle}}
				</view>
			</view>
		</swiper-item>
	</swiper>
</view>

最后看实现的轮播图效果:
在这里插入图片描述
最后看看本文实现的最后效果:
在这里插入图片描述

最后

本文内容到这里就结束了,下期会带大家继续完成首页部分的功能和一些细节,并且完成api的封装。

  • 0
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Beiyux

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值