Files
xhs-examples/xhs-mini-demos/component-case/slider/slider.js
2025-09-14 00:21:54 +08:00

114 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
const pageData = {
onShareAppMessage() {
return {
title: 'slider',
path: 'page/component/pages/slider/slider'
};
},
data: {
min: 0,
max: 100,
step: 1,
disabled: false,
value: 0,
color: '#e9e9e9',
selectedColor: '#1aad19',
activeColor: '#1aad19',
backgroundColor: 'transparent',
blockSize: 28,
blockColor: '#fff',
showValue: false,
onChangeValue: '',
onChangeingValue: ''
},
changeMin({
detail
}) {
this.setData({
min: detail.value
});
},
changeMax({
detail
}) {
this.setData({
max: detail.value
});
},
changeStep({
detail
}) {
this.setData({
step: detail.value
});
},
changeDisabled() {
this.setData({
disabled: !this.data.disabled
});
},
changeValue({
detail
}) {
this.setData({
value: detail.value
});
},
changeActiveColor({
detail
}) {
this.setData({
activeColor: detail.value
});
},
changeBackgroundColor({
detail
}) {
this.setData({
backgroundColor: detail.value
});
},
changeBlockSize({
detail
}) {
this.setData({
blockSize: detail.value
});
},
changeBlockColor({
detail
}) {
this.setData({
blockColor: detail.value
});
},
changeShowValue() {
this.setData({
showValue: !this.data.showValue
});
},
onChange({
detail
}) {
this.setData({
onChangeValue: detail.value
});
},
onChangeing({
detail
}) {
this.setData({
onChangeingValue: detail.value
});
}
};
for (let i = 1; i < 5; ++i) {
(function (index) {
pageData[`slider${index}change`] = function (e) {
console.log(`slider${index}发生change事件携带值为`, e.detail.value);
};
})(i);
}
Page(__mergePageOptions(pageData, __templateJs));