提交 50586672 编写于 作者: H hdx

slider-100: 点击时更新其它 slider

上级 483be9be
...@@ -6,19 +6,19 @@ ...@@ -6,19 +6,19 @@
<view class="flex-row"> <view class="flex-row">
<view class="flex-fill"> <view class="flex-fill">
<slider ref="slider1" v-for="(_, index1) in 25" :key="index1" class="slider" @changing="sliderChanging" <slider ref="slider1" v-for="(_, index1) in 25" :key="index1" class="slider" @changing="sliderChanging"
:value="sliderValue" :block-size="20" :show-value="true" /> @change="sliderChange" :value="sliderValue" :block-size="20" :show-value="true" />
</view> </view>
<view class="flex-fill"> <view class="flex-fill">
<slider ref="slider2" v-for="(_, index2) in 25" :key="index2" class="slider" @changing="sliderChanging" <slider ref="slider2" v-for="(_, index2) in 25" :key="index2" class="slider" @changing="sliderChanging"
:value="sliderValue" :block-size="20" :show-value="true" /> @change="sliderChange" :value="sliderValue" :block-size="20" :show-value="true" />
</view> </view>
<view class="flex-fill"> <view class="flex-fill">
<slider ref="slider3" v-for="(_, index3) in 25" :key="index3" class="slider" @changing="sliderChanging" <slider ref="slider3" v-for="(_, index3) in 25" :key="index3" class="slider" @changing="sliderChanging"
:value="sliderValue" :block-size="20" :show-value="true" /> @change="sliderChange" :value="sliderValue" :block-size="20" :show-value="true" />
</view> </view>
<view class="flex-fill"> <view class="flex-fill">
<slider ref="slider4" v-for="(_, index4) in 25" :key="index4" class="slider" @changing="sliderChanging" <slider ref="slider4" v-for="(_, index4) in 25" :key="index4" class="slider" @changing="sliderChanging"
:value="sliderValue" :block-size="20" :show-value="true" /> @change="sliderChange" :value="sliderValue" :block-size="20" :show-value="true" />
</view> </view>
</view> </view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
...@@ -35,28 +35,33 @@ ...@@ -35,28 +35,33 @@
} }
}, },
methods: { methods: {
sliderChange(e : SliderChangeEvent) {
this.updateSliderValue(e.detail.value)
},
sliderChanging(e : SliderChangeEvent) { sliderChanging(e : SliderChangeEvent) {
// this.sliderValue = e.detail.value this.updateSliderValue(e.detail.value)
},
updateSliderValue(value : Number) {
// this.sliderValue = value
// TODO 跳过vue框架,直接修改原生组件 // TODO 跳过vue框架,直接修改原生组件
const sliderValue = e.detail.value;
(this.$refs["slider1"]! as ComponentPublicInstance[]).forEach((item) => { (this.$refs["slider1"]! as ComponentPublicInstance[]).forEach((item) => {
item.$data["$sliderValue"] = sliderValue item.$data["$sliderValue"] = value
item.$callMethod("_onRender") item.$callMethod("_onRender")
}); });
(this.$refs["slider2"]! as ComponentPublicInstance[]).forEach((item) => { (this.$refs["slider2"]! as ComponentPublicInstance[]).forEach((item) => {
item.$data["$sliderValue"] = sliderValue item.$data["$sliderValue"] = value
item.$callMethod("_onRender") item.$callMethod("_onRender")
}); });
(this.$refs["slider3"]! as ComponentPublicInstance[]).forEach((item) => { (this.$refs["slider3"]! as ComponentPublicInstance[]).forEach((item) => {
item.$data["$sliderValue"] = sliderValue item.$data["$sliderValue"] = value
item.$callMethod("_onRender") item.$callMethod("_onRender")
}); });
(this.$refs["slider4"]! as ComponentPublicInstance[]).forEach((item) => { (this.$refs["slider4"]! as ComponentPublicInstance[]).forEach((item) => {
item.$data["$sliderValue"] = sliderValue item.$data["$sliderValue"] = value
item.$callMethod("_onRender") item.$callMethod("_onRender")
}); });
}, }
}, },
} }
</script> </script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册