chore(Slider): format code (#10055)

This commit is contained in:
neverland 2021-12-16 20:11:40 +08:00 committed by GitHub
parent 3976d5583d
commit 8fd2c0570e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 18 deletions

View File

@ -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

View File

@ -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 } |
### 样式变量

View File

@ -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 (
<div class={bem('button')} style={this.buttonStyle} />
)
}
return <div class={bem('button')} style={this.buttonStyle} />;
};
return (
<div