Skip to content

Commit

Permalink
fix: carousel not work with variable-width #3977
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Apr 27, 2021
1 parent 5eeaaae commit 58ffdd9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/vc-slick/src/inner-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default {
slideCount: children.length,
});
children.forEach(child => {
const childWidth = child.props.width.split('px')[0];
const childWidth = child.props.style?.width?.split('px')[0] || 0;
childrenWidths.push(childWidth);
trackWidth += childWidth;
});
Expand Down
2 changes: 1 addition & 1 deletion components/vc-slick/src/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default defineComponent({
for (let j = i; j < i + settings.rows * settings.slidesPerRow; j += settings.slidesPerRow) {
const row = [];
for (let k = j; k < j + settings.slidesPerRow; k += 1) {
if (settings.variableWidth && children[k].props.style) {
if (settings.variableWidth && children[k].props?.style) {
currentWidth = children[k].props.style.width;
}
if (k >= children.length) break;
Expand Down
4 changes: 1 addition & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ module.exports = {
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: true,
},
options: {},
},
'css-loader',
],
Expand Down

0 comments on commit 58ffdd9

Please sign in to comment.