feat: 添加 swiper
parent
6fd2bdebd5
commit
e3f9f2c1c3
3
app.json
3
app.json
|
@ -3,7 +3,8 @@
|
|||
"pages/component/index/index",
|
||||
"pages/component/view/view",
|
||||
"pages/API/index/index",
|
||||
"pages/component/scroll-view/scroll-view"
|
||||
"pages/component/scroll-view/scroll-view",
|
||||
"pages/component/swiper/swiper"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
Page({
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: 'swiper',
|
||||
path: 'pages/component/swiper/swiper'
|
||||
}
|
||||
},
|
||||
|
||||
data: {
|
||||
background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
|
||||
indicatorDots: true,
|
||||
vertical: false,
|
||||
autoplay: false,
|
||||
interval: 2000,
|
||||
duration: 500
|
||||
},
|
||||
|
||||
changeIndicatorDots() {
|
||||
this.setData({
|
||||
indicatorDots: !this.data.indicatorDots
|
||||
})
|
||||
},
|
||||
|
||||
changeAutoplay() {
|
||||
this.setData({
|
||||
autoplay: !this.data.autoplay
|
||||
})
|
||||
},
|
||||
|
||||
intervalChange(e) {
|
||||
this.setData({
|
||||
interval: e.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
durationChange(e) {
|
||||
this.setData({
|
||||
duration: e.detail.value
|
||||
})
|
||||
}
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"navigationBarTitleText": "swiper"
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<import src="../../../common/head.wxml" />
|
||||
<import src="../../../common/foot.wxml" />
|
||||
|
||||
<view class="container">
|
||||
<template is="head" data="{{title: 'swiper'}}"/>
|
||||
|
||||
<view class="page-body">
|
||||
<view class="page-section page-section-spacing swiper">
|
||||
<swiper indicator-dots="{{indicatorDots}}"
|
||||
autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
|
||||
<block wx:for="{{background}}" wx:key="*this">
|
||||
<swiper-item>
|
||||
<view class="swiper-item {{item}}"></view>
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
<view class="page-section" style="margin-top: 20px;margin-bottom: 0;">
|
||||
<view class="weui-cells weui-cells_after-title">
|
||||
<view class="weui-cell weui-cell_switch">
|
||||
<view class="weui-cell__bd">指示点</view>
|
||||
<view class="weui-cell__ft">
|
||||
<switch checked="{{indicatorDots}}" bindchange="changeIndicatorDots" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_switch">
|
||||
<view class="weui-cell__bd">自动播放</view>
|
||||
<view class="weui-cell__ft">
|
||||
<switch checked="{{autoplay}}" bindchange="changeAutoplay" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="page-section page-section-spacing">
|
||||
<view class="page-section-title">
|
||||
<text>幻灯片切换时长(ms)</text>
|
||||
<text class="info">{{duration}}</text>
|
||||
</view>
|
||||
<slider bindchange="durationChange" value="{{duration}}" min="500" max="2000"/>
|
||||
<view class="page-section-title">
|
||||
<text>自动播放间隔时长(ms)</text>
|
||||
<text class="info">{{interval}}</text>
|
||||
</view>
|
||||
<slider bindchange="intervalChange" value="{{interval}}" min="2000" max="10000"/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<template is="foot" />
|
||||
</view>
|
|
@ -0,0 +1,28 @@
|
|||
@import "../../common/lib/weui.wxss";
|
||||
|
||||
button{
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
button:last-child{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.page-section-title{
|
||||
padding: 0;
|
||||
}
|
||||
.swiper-item{
|
||||
display: block;
|
||||
height: 150px;
|
||||
}
|
||||
.page-section-title{
|
||||
margin-top: 30px;
|
||||
position: relative;
|
||||
}
|
||||
.info{
|
||||
position: absolute;
|
||||
right: 0;
|
||||
color: #353535;
|
||||
font-size: 15px;
|
||||
}
|
||||
.page-foot{
|
||||
margin-top: 25px;
|
||||
}
|
Loading…
Reference in New Issue