swiper.uvue 2.9 KB
Newer Older
杜庆泉's avatar
杜庆泉 已提交
1 2 3 4
<template>
	<view>
		<page-head title="swiper,可滑动视图"></page-head>
		<view class="uni-margin-wrap">
杜庆泉's avatar
杜庆泉 已提交
5
			<swiper class="swiper" circular :indicator-dots="dotsSelect" :autoplay="autoplaySelect" :interval="intervalSelect"  :circular="circularSelect" :indicator-color="indicatorColor" :indicator-active-color="indicatorColorActive">
杜庆泉's avatar
杜庆泉 已提交
6 7 8 9 10 11 12 13 14 15 16
				<swiper-item>
					<view class="swiper-item uni-bg-red">A</view>
				</swiper-item>
				<swiper-item>
					<view class="swiper-item uni-bg-green">B</view>
				</swiper-item>
				<swiper-item>
					<view class="swiper-item uni-bg-blue">C</view>
				</swiper-item>
			</swiper>
		</view>
杜庆泉's avatar
杜庆泉 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
		<view class="uni-list">
		  <view class="uni-list-cell uni-list-cell-pd">
		    <view class="uni-list-cell-db">是否显示面板指示点</view>
		    <switch :checked="dotsSelect" @change="dotsChange"/>
		  </view>
		  <view class="uni-list-cell uni-list-cell-pd">
		    <view class="uni-list-cell-db">是否自动切换</view>
		    <switch :checked="autoplaySelect" @change="autoplayChange"/>
		  </view>
		  <view class="uni-list-cell uni-list-cell-pd">
		    <view class="uni-list-cell-db">是否循环</view>
		    <switch :checked="circularSelect" @change="circularChange"/>
		  </view>
		  <view class="uni-title">间隔时间</view>
		  <view>
		    <slider @change="sliderChange" :value="1000" :min="500" :max="5000" :show-value="true" />
		  </view>
		  <view class="uni-list-cell uni-list-cell-pd">
		    <view class="uni-list-cell-db">定制指示器颜色</view>
		    <switch :checked="indicatorColorSelect" @change="indicatorColorChange"/>
		  </view>
		  
		  
		</view>
杜庆泉's avatar
杜庆泉 已提交
41 42 43 44 45 46 47 48 49 50


	</view>
</template>
<script>
	export default {
		data() {
			return {
				background: ['color1', 'color2', 'color3'],
				interval: 2000,
杜庆泉's avatar
杜庆泉 已提交
51 52 53 54 55 56 57
				dotsSelect:false,
				autoplaySelect:false,
				circularSelect:false,
				indicatorColorSelect:false,
				intervalSelect:1000,
				indicatorColor:"",
				indicatorColorActive:"",
杜庆泉's avatar
杜庆泉 已提交
58 59 60
			}
		},
		methods: {
杜庆泉's avatar
杜庆泉 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
			dotsChange: function (e : SwitchChangeEvent) {
				this.dotsSelect = e.detail.value
			},
			autoplayChange: function (e : SwitchChangeEvent) {
				this.autoplaySelect = e.detail.value
			},
			circularChange: function (e : SwitchChangeEvent) {
				this.circularSelect = e.detail.value
				console.log(this.circularSelect)
			},
			sliderChange(e : SliderChangeEvent) {
			  this.intervalSelect = e.detail.value
			},
			indicatorColorChange(e : SwitchChangeEvent) {
				this.indicatorColorSelect = e.detail.value
				if(this.indicatorColorSelect){
					// 选择了定制指示器颜色
					this.indicatorColor = "#ff00ff"
					this. indicatorColorActive = "#0000ff"
				}else{
					// 没有选择颜色
					this.indicatorColor = ""
					this. indicatorColorActive = ""
				}
			}
杜庆泉's avatar
杜庆泉 已提交
86 87 88 89 90 91 92 93 94 95 96 97 98
		}
	}
</script>

<style>
	.uni-margin-wrap {
		width:690rpx;
		width: 100%;;
	}
	.swiper {
		height: 300rpx;
	}
	.swiper-item {
杜庆泉's avatar
杜庆泉 已提交
99
		width: 100%;
杜庆泉's avatar
杜庆泉 已提交
100 101 102 103 104 105
		height: 300rpx;
		line-height: 300rpx;
		text-align: center;
	}

</style>