diff --git a/src/slider/README.md b/src/slider/README.md index ca16876bb..e09be4f28 100644 --- a/src/slider/README.md +++ b/src/slider/README.md @@ -168,11 +168,11 @@ export default { ### Slots -| Name | Description | Arguments | -| ------------ | ------------------------------ | ----------------- | -| button | Custom button | - | -| left-button | Custom left button (in range) | { value: number } | -| right-button | Custom right button (in range) | { value: number } | +| Name | Description | Arguments | +| ----------------------- | ------------------------------ | ----------------- | +| button | Custom button | - | +| left-button `v2.12.38` | Custom left button (in range) | { value: number } | +| right-button `v2.12.38` | Custom right button (in range) | { value: number } | ### Less Variables diff --git a/src/slider/README.zh-CN.md b/src/slider/README.zh-CN.md index 829284e68..13d0d1a26 100644 --- a/src/slider/README.zh-CN.md +++ b/src/slider/README.zh-CN.md @@ -174,11 +174,11 @@ export default { ### Slots -| 名称 | 说明 | 参数 | -| ------------ | ---------------------------------- | ----------------- | -| button | 自定义滑动按钮 | - | -| left-button | 自定义左侧滑块按钮(双滑块模式下) | { value: number } | -| right-button | 自定义右侧滑块按钮(双滑块模式下) | { value: number } | +| 名称 | 说明 | 参数 | +| --- | --- | --- | +| button | 自定义滑动按钮 | - | +| left-button `v2.12.38` | 自定义左侧滑块按钮(双滑块模式下) | { value: number } | +| right-button `v2.12.38` | 自定义右侧滑块按钮(双滑块模式下) | { value: number } | ### 样式变量 diff --git a/src/slider/index.js b/src/slider/index.js index 2213aa2e2..fe91d9ddb 100644 --- a/src/slider/index.js +++ b/src/slider/index.js @@ -236,33 +236,38 @@ export default createComponent({ const renderButton = (i) => { const map = ['left', 'right']; const isNumber = typeof i === 'number'; - const current = isNumber ? this.value[i] : this.value + const current = isNumber ? this.value[i] : this.value; + const getClassName = () => { if (isNumber) { return `button-wrapper-${map[i]}`; } return `button-wrapper`; }; + const getRefName = () => { if (isNumber) { return `wrapper${i}`; } return `wrapper`; }; + const renderButtonContent = () => { if (isNumber) { - const slot = this.slots(i === 0 ? 'left-button' : 'right-button', {value: current}) + const slot = this.slots(i === 0 ? 'left-button' : 'right-button', { + value: current, + }); if (slot) { - return slot + return slot; } } + if (this.slots('button')) { - return this.slots('button') + return this.slots('button'); } - return ( -
- ) - } + + return
; + }; return (