|
|
@@ -35,9 +35,16 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div v-else :style="boxCss">
|
|
|
- <el-carousel height="384px" arrow="always" autoplay>
|
|
|
+ <el-carousel :height="carouselHeight" arrow="always" autoplay>
|
|
|
<el-carousel-item v-for="(item1, index1) in dataList" :key="index1" class="w100% h100%">
|
|
|
- <div class="goods-bos">
|
|
|
+ <div
|
|
|
+ class="goods-bos"
|
|
|
+ :ref="
|
|
|
+ (el) => {
|
|
|
+ if (el) goodsBoxRefs[index1] = el;
|
|
|
+ }
|
|
|
+ "
|
|
|
+ >
|
|
|
<div
|
|
|
v-for="(item, index) in item1"
|
|
|
:key="index"
|
|
|
@@ -88,14 +95,32 @@ const props = defineProps<{
|
|
|
}>();
|
|
|
const componentData = props.row || {};
|
|
|
const original = ref<any>([{}, {}, {}, {}, {}]);
|
|
|
+const carouselHeight = ref('384px');
|
|
|
+const goodsBoxRefs = ref({});
|
|
|
|
|
|
onMounted(() => {
|
|
|
if (props.datas) {
|
|
|
} else {
|
|
|
getDataList();
|
|
|
}
|
|
|
+ window.addEventListener('resize', calcCarouselHeight);
|
|
|
});
|
|
|
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ window.removeEventListener('resize', calcCarouselHeight);
|
|
|
+});
|
|
|
+
|
|
|
+// 计算高度的函数
|
|
|
+const calcCarouselHeight = () => {
|
|
|
+ nextTick(() => {
|
|
|
+ const el = goodsBoxRefs.value[0];
|
|
|
+ if (el) {
|
|
|
+ // 获取真实渲染高度并赋值给轮播图
|
|
|
+ carouselHeight.value = el.offsetHeight + 'px';
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
const getDataList = () => {
|
|
|
original.value = [{}, {}, {}, {}, {}];
|
|
|
const apiFunc = componentData.clientId && componentData.clientId !== 'undefined' ? getCustomerProductPage : getDiyProductPage;
|