slider-100.uvue 2.4 KB
Newer Older
H
hdx 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2
  <!-- #ifdef APP -->
H
hdx 已提交
3
  <scroll-view class="page">
DCloud-WZF's avatar
DCloud-WZF 已提交
4
    <!-- #endif -->
H
hdx 已提交
5 6 7
    <page-head :title="title"></page-head>
    <view class="flex-row">
      <view class="flex-fill">
8 9
        <slider ref="slider1" v-for="(_, index1) in 25" :key="index1" class="slider" @changing="sliderChanging"
          :value="sliderValue" :block-size="20" :show-value="true" />
H
hdx 已提交
10 11
      </view>
      <view class="flex-fill">
12 13
        <slider ref="slider2" v-for="(_, index2) in 25" :key="index2" class="slider" @changing="sliderChanging"
          :value="sliderValue" :block-size="20" :show-value="true" />
H
hdx 已提交
14 15
      </view>
      <view class="flex-fill">
16 17
        <slider ref="slider3" v-for="(_, index3) in 25" :key="index3" class="slider" @changing="sliderChanging"
          :value="sliderValue" :block-size="20" :show-value="true" />
H
hdx 已提交
18 19
      </view>
      <view class="flex-fill">
20 21
        <slider ref="slider4" v-for="(_, index4) in 25" :key="index4" class="slider" @changing="sliderChanging"
          :value="sliderValue" :block-size="20" :show-value="true" />
H
hdx 已提交
22 23
      </view>
    </view>
DCloud-WZF's avatar
DCloud-WZF 已提交
24 25 26
    <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
H
hdx 已提交
27 28
</template>

H
hdx 已提交
29 30 31 32 33
<script>
  export default {
    data() {
      return {
        title: 'slider 滑块 x 100',
H
hdx 已提交
34
        sliderValue: 50
H
hdx 已提交
35
      }
DCloud-WZF's avatar
DCloud-WZF 已提交
36
    },
H
hdx 已提交
37
    methods: {
H
hdx 已提交
38
      sliderChanging(e : SliderChangeEvent) {
39 40
        // this.sliderValue = e.detail.value

41
        // TODO 跳过vue框架,直接修改原生组件
42 43
        const sliderValue = e.detail.value;
        (this.$refs["slider1"]! as ComponentPublicInstance[]).forEach((item) => {
44
          item.$data["$sliderValue"] = sliderValue
45 46 47
          item.$callMethod("_onRender")
        });
        (this.$refs["slider2"]! as ComponentPublicInstance[]).forEach((item) => {
48
          item.$data["$sliderValue"] = sliderValue
49 50 51
          item.$callMethod("_onRender")
        });
        (this.$refs["slider3"]! as ComponentPublicInstance[]).forEach((item) => {
52
          item.$data["$sliderValue"] = sliderValue
53 54 55
          item.$callMethod("_onRender")
        });
        (this.$refs["slider4"]! as ComponentPublicInstance[]).forEach((item) => {
56
          item.$data["$sliderValue"] = sliderValue
57 58
          item.$callMethod("_onRender")
        });
H
hdx 已提交
59 60 61
      },
    },
  }
H
hdx 已提交
62 63 64
</script>

<style>
H
hdx 已提交
65 66 67 68 69 70 71
  .page {
    flex: 1;
  }

  .flex-row {
    flex-direction: row;
  }
H
hdx 已提交
72

H
hdx 已提交
73 74 75
  .flex-fill {
    flex: 1;
  }
H
hdx 已提交
76

H
hdx 已提交
77
  .slider {
78
    margin: 1px 0.5px;
H
hdx 已提交
79 80
  }
</style>