uni-app基础学习

scroll-view组件

使用方法

代码

<scroll-view class="scroll" scroll-x="true">
			<view class="group">
				<view class="item">111</view>
				<view class="item">111</view>
				<view class="item">111</view>
				<view class="item">111</view>
				<view class="item">111</view>
			</view>
</scroll-view>

样式

	.scroll {
		border: 1px solid pink;
		box-sizing: border-box;
		height: 220rpx;

		.group {
			white-space: nowrap;

			.item {
				width: 200rpx;
				height: 220rpx;
				background-color: orange;
				display: inline-block;
			}
		}
	}

注解:三级盒子模型 最外层定义宽/高;中间使用white-space:nowrap 使最内层盒子不换行;最内层盒子定义宽高,注意要使用display:inline-block 使块级元素变为行内块级元素。

效果滚动条在不同的浏览器上的显示效果不一样

swiper组件

使用方法

代码

<swiper class="swiper" autoplay="true" interval="3000" circular="true" duration="200">
			<swiper-item class="item">
				<image src="/static/images/pic1.jpg" mode="aspectFill"></image>
			</swiper-item>
			<swiper-item class="item">
				<image src="/static/images/pic2.jpg" mode="aspectFill"></image>
			</swiper-item>
			<swiper-item class="item">
				<image src="/static/images/pic3.jpg" mode="aspectFill"></image>
			</swiper-item>
		</swiper>

注解:mode属性下的aspectFill是适应短边,长边按比例自动缩放;aspectFit是适应长边

样式

.swiper {
		.item{
			image{
				width: 100%;
				height: 400rpx;
			}
		}
	}

注解:要为image设置宽高

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值