提交 91aa9765 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

refactor: 优化 slider-100 示例

上级 b51f67e5
<template> <template>
<scroll-view class="page"> <!-- #ifdef APP -->
<page-head :title="title"></page-head> <scroll-view class="page">
<view class="grid-view"> <!-- #endif -->
<slider ref="slider" class="slider" v-for="(_, index) in 100" :key="index" @changing="sliderChanging" <page-head :title="title"></page-head>
@change="sliderChange" :value="sliderValue" :block-size="20" :show-value="true" /> <view class="grid-view">
</view> <slider ref="slider" class="slider" v-for="(_, index) in 100" :key="index" @changing="sliderChanging"
</scroll-view> @change="sliderChange" :value="sliderValue" :block-size="20" :show-value="true" />
</template> </view>
<!-- #ifdef APP -->
<script> </scroll-view>
export default { <!-- #endif -->
data() { </template>
return {
title: 'slider 滑块 x 100', <script>
sliderValue: 50 export default {
} data() {
}, return {
methods: { title: 'slider 滑块 x 100',
sliderChange(e : UniSliderChangeEvent) { sliderValue: 50
this.updateSliderValue(e.detail.value) }
}, },
sliderChanging(e : UniSliderChangeEvent) { methods: {
this.updateSliderValue(e.detail.value) sliderChange(e : UniSliderChangeEvent) {
}, this.updateSliderValue(e.detail.value)
updateSliderValue(value : number) { },
// TODO 跳过vue框架,直接修改原生组件 sliderChanging(e : UniSliderChangeEvent) {
(this.$refs["slider"] as UniSliderElement[]).forEach((item) => { this.updateSliderValue(e.detail.value)
item.value = value },
}); updateSliderValue(value : number) {
} // TODO 跳过vue框架,直接修改原生组件
}, (this.$refs["slider"] as UniSliderElement[]).forEach((item) => {
} item.value = value
</script> });
}
<style> },
.page { }
flex: 1; </script>
}
<style>
.grid-view { .page {
flex-direction: row; flex: 1;
flex-wrap: wrap; }
}
.grid-view {
.slider { flex-direction: row;
width: 25%; flex-wrap: wrap;
margin-top: 1px; }
margin-bottom: 1px;
} .slider {
width: 25%;
margin-top: 1px;
margin-bottom: 1px;
}
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册