mirror of
				https://gitee.com/vant-contrib/vant.git
				synced 2025-11-04 12:52:08 +08:00 
			
		
		
		
	feat(Progress): add track-color prop (#4789)
This commit is contained in:
		
							parent
							
								
									4c2cf8e2cb
								
							
						
					
					
						commit
						95598e8842
					
				@ -68,6 +68,7 @@ Use `pivot-text` to custom text,use `color` to custom bar color
 | 
				
			|||||||
| stroke-width | Stroke width | *string \| number* | `4px` | 2.2.1 |
 | 
					| stroke-width | Stroke width | *string \| number* | `4px` | 2.2.1 |
 | 
				
			||||||
| show-pivot | Whether to show text | *boolean* | `true` | - |
 | 
					| show-pivot | Whether to show text | *boolean* | `true` | - |
 | 
				
			||||||
| color | Color | *string* | `#1989fa` | - |
 | 
					| color | Color | *string* | `#1989fa` | - |
 | 
				
			||||||
 | 
					| text-color | Text color | *string* | `#fff` | - |
 | 
				
			||||||
 | 
					| track-color | Track color | *string* | `#e5e5e5` | 2.2.9 |
 | 
				
			||||||
| pivot-text | Text | *string* | percentage | - |
 | 
					| pivot-text | Text | *string* | percentage | - |
 | 
				
			||||||
| pivot-color | Text background color | *string* | inherit progress color | - |
 | 
					| pivot-color | Text background color | *string* | inherit progress color | - |
 | 
				
			||||||
| text-color | Text color | *string* | `#fff` | - |
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -71,6 +71,7 @@ Vue.use(Progress);
 | 
				
			|||||||
| stroke-width | 进度条粗细,默认单位为`px` | *string \| number* | `4px` | 2.2.1 |
 | 
					| stroke-width | 进度条粗细,默认单位为`px` | *string \| number* | `4px` | 2.2.1 |
 | 
				
			||||||
| show-pivot | 是否显示进度文字 | *boolean* | `true` | - |
 | 
					| show-pivot | 是否显示进度文字 | *boolean* | `true` | - |
 | 
				
			||||||
| color | 进度条颜色 | *string* | `#1989fa` | - |
 | 
					| color | 进度条颜色 | *string* | `#1989fa` | - |
 | 
				
			||||||
| text-color | 进度条文字颜色 | *string* | `#fff` | - |
 | 
					| text-color | 进度文字颜色 | *string* | `#fff` | - |
 | 
				
			||||||
 | 
					| track-color | 轨道颜色 | *string* | `#e5e5e5` | 2.2.9 |
 | 
				
			||||||
| pivot-text | 文字显示 | *string* | 百分比文字 | - |
 | 
					| pivot-text | 文字显示 | *string* | 百分比文字 | - |
 | 
				
			||||||
| pivot-color | 文字背景色 | *string* | 与进度条颜色一致 | - |
 | 
					| pivot-color | 文字背景色 | *string* | 与进度条颜色一致 | - |
 | 
				
			||||||
 | 
				
			|||||||
@ -8,6 +8,7 @@ export default createComponent({
 | 
				
			|||||||
    inactive: Boolean,
 | 
					    inactive: Boolean,
 | 
				
			||||||
    pivotText: String,
 | 
					    pivotText: String,
 | 
				
			||||||
    pivotColor: String,
 | 
					    pivotColor: String,
 | 
				
			||||||
 | 
					    trackColor: String,
 | 
				
			||||||
    strokeWidth: [String, Number],
 | 
					    strokeWidth: [String, Number],
 | 
				
			||||||
    percentage: {
 | 
					    percentage: {
 | 
				
			||||||
      type: Number,
 | 
					      type: Number,
 | 
				
			||||||
@ -70,12 +71,10 @@ export default createComponent({
 | 
				
			|||||||
      width: (this.progressWidth * percentage) / 100 + 'px'
 | 
					      width: (this.progressWidth * percentage) / 100 + 'px'
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let wrapperStyle;
 | 
					    const wrapperStyle = {
 | 
				
			||||||
    if (this.strokeWidth) {
 | 
					      background: this.trackColor,
 | 
				
			||||||
      wrapperStyle = {
 | 
					      height: addUnit(this.strokeWidth)
 | 
				
			||||||
        height: addUnit(this.strokeWidth)
 | 
					    };
 | 
				
			||||||
      };
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
      <div class={bem()} style={wrapperStyle}>
 | 
					      <div class={bem()} style={wrapperStyle}>
 | 
				
			||||||
 | 
				
			|||||||
@ -16,3 +16,13 @@ test('calc width', async () => {
 | 
				
			|||||||
  await later();
 | 
					  await later();
 | 
				
			||||||
  expect(wrapper).toMatchSnapshot();
 | 
					  expect(wrapper).toMatchSnapshot();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('track color prop', async () => {
 | 
				
			||||||
 | 
					  const wrapper = mount(Progress, {
 | 
				
			||||||
 | 
					    propsData: {
 | 
				
			||||||
 | 
					      trackColor: 'green'
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  expect(wrapper.element.style.background).toEqual('green');
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user