Today, I record how to achieve the effect of the rotation chart when developing the small program. Not much to say, go directly to the code:
<!-- 1. Home Rotary Map --> <view> <swiper class="my-swiper" autoplay="true" indicator-dots="true" indicator-active-color="#fff" circular="true"> <block wx:for="{{imgUrls}}"> <swiper-item class="sw-img"> <image src="{{item}}" mode="widthFix"></image> </swiper-item> </block> </swiper> </view>
Rotation, using swiper components, there are many attributes, generally the following are more commonly used:
- autoplay="true": Set autoplay
- indicator-dots="true": Whether the panel pointer is displayed or not
- indicator-active-color="#fff": the current selected indicator color
- circular="true": whether to use cohesive sliding
- Interval: automatic switching interval, default 5000ms
Data in js:
Page({ data: { imgUrls: ["https://picabstract-preview-ftn.weiyun.com/ftn_pic_abs_v3/3c5e6138079dc63ebe3688afff0a63b0fb56fbe1702bb754e33c4ca874b872ced8df2f995cd0d7ae9ce9db487f8f90a7?pictype=scale&from=30013&version=3.3.3.3&uin=522083376&fname=Natural.png&size=750", "https://picabstract-preview-ftn.weiyun.com/ftn_pic_abs_v3/4e5e95cc21cb5e2b2f5ecfdc0f7406dbc731207642cda81a9b880c79c4ee624fc37b5d4548d8cad8f7c2ec585bef9c85?pictype=scale&from=30013&version=3.3.3.3&uin=522083376&fname=DSC_0026.JPG&size=750", 'https://picabstract-preview-ftn.weiyun.com/ftn_pic_abs_v3/6283d77c69833853929662a4e86f089ec4570433af79a4ab614dd90d05f2cd6c5ab142f2df15172714a76bdced89d82f?pictype=scale&from=30013&version=3.3.3.3&uin=522083376&fname=DSC_0061.JPG&size=750', 'https://picabstract-preview-ftn.weiyun.com/ftn_pic_abs_v3/55d0ac2a67bb6d57a343a61070ea23de0457a536ebe9415e1b39ec8c3c6b3fe343b70f1a1a1c211d3c04e97d5d1c30be?pictype=scale&from=30013&version=3.3.3.3&uin=522083376&fname=DSC_0059.JPG&size=750', 'https://picabstract-preview-ftn.weiyun.com/ftn_pic_abs_v3/0d2bf2e9fdd34a7167b65750b3d808acda73ff0541f78d288bd636a723bf51bdbe191aa297de4d1bd72a427bb9ca6f41?pictype=scale&from=30013&version=3.3.3.3&uin=522083376&fname=DSC_0058.JPG&size=750' ] },