fix: carousel not work with variable-width #3977

pull/4013/head
tangjinzhou 4 years ago
parent 5eeaaae08c
commit 58ffdd9728

@ -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;
});

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

@ -1 +1 @@
Subproject commit 31d85319dcc0438b3c80957c99f57b931b047c11
Subproject commit ee89a33312a7bb5c65c6080c12613b9ca1474aaf

@ -118,9 +118,7 @@ module.exports = {
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: true,
},
options: {},
},
'css-loader',
],

Loading…
Cancel
Save