微信小程序Day1
scroll-view:滑轮组件
代码示例:
wxml:
<scroll-view class="container1" scroll-y>
<image src="/image/1.jpg" mode="aspectFit"></image>
<view>B</view>
<view>C</view>
</scroll-view>
wxss:
//定义滑轮视图
.container1 view{
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
}
//渲染滑轮视图
.container1 view:nth-child(1){
background-color: lightgreen;
}
.container1 view:nth-child(2){
background-color: rgb(144, 158, 238);
}
.container1 view:nth-child(3){
background-color: rgb(238, 144, 172);
}
//定义滑轮组件
.container1{
border:1px solid red;
height: 120px;
width: 100px;
}
swiper:轮播图组件
代码示例:
wxml:
<swiper class="swiper-container" indicator-dots>
<swiper-item>
<image src="/image/1.jpg" mode="widthFix" class="item"></image> //此处image属性链接:https://developers.weixin.qq.com/miniprogram/dev/component/image.html
</swiper-item>
<swiper-item>
<view class="item">B</view>
</swiper-item>
<swiper-item>
<view class="item">C</view>
</swiper-item>
</swiper>
wxss:
.swiper-container{
height: 150px;
}
.item{
height: 100%;
line-height: 150px;
text-align: center;
}
swiper-item:nth-child(2) .item{
background-color: rgb(226, 77, 146);
}
swiper-item:nth-child(3) .item{
background-color: rgb(37, 148, 46);
}
text : 文本组件
text-align:文本位置(如居中)
button:按钮组件
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~