Skip to content

Commit 58ffdd9

Browse files
committed
fix: carousel not work with variable-width #3977
1 parent 5eeaaae commit 58ffdd9

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

components/vc-slick/src/inner-slider.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export default {
116116
slideCount: children.length,
117117
});
118118
children.forEach(child => {
119-
const childWidth = child.props.width.split('px')[0];
119+
const childWidth = child.props.style?.width?.split('px')[0] || 0;
120120
childrenWidths.push(childWidth);
121121
trackWidth += childWidth;
122122
});

components/vc-slick/src/slider.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export default defineComponent({
155155
for (let j = i; j < i + settings.rows * settings.slidesPerRow; j += settings.slidesPerRow) {
156156
const row = [];
157157
for (let k = j; k < j + settings.slidesPerRow; k += 1) {
158-
if (settings.variableWidth && children[k].props.style) {
158+
if (settings.variableWidth && children[k].props?.style) {
159159
currentWidth = children[k].props.style.width;
160160
}
161161
if (k >= children.length) break;

webpack.config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ module.exports = {
118118
use: [
119119
{
120120
loader: MiniCssExtractPlugin.loader,
121-
options: {
122-
hmr: true,
123-
},
121+
options: {},
124122
},
125123
'css-loader',
126124
],

0 commit comments

Comments
 (0)