修改自定义轮播显示

This commit is contained in:
于肖磊
2025-01-08 16:13:08 +08:00
parent ec440182a4
commit ffbead8c02
2 changed files with 8 additions and 6 deletions

View File

@ -190,9 +190,6 @@ watchEffect(() => {
const data_source_carousel_col = Number(form.value.data_source_carousel_col);
// 判断是平移还是整屏滚动
slides_per_group.value = new_style.value.rolling_fashion == 'translation' ? 1 : Number(data_source_carousel_col);
// 商品数量大于列数的时候,高度是列数,否则是当前的数量
const col = data_source_content_list.value.length > Number(data_source_carousel_col) ? Number(data_source_carousel_col) : data_source_content_list.value.length;
slides_per_view.value = col;
let num = 0;
// 轮播图数量
if (!isEmpty(data_source_content_list.value)) {
@ -202,7 +199,11 @@ watchEffect(() => {
// 轮播图高度控制
if (form.value.data_source_direction == 'horizontal') {
swiper_height.value = props.dataHeight * custom_scale.value + padding_top + padding_bottom + margin_bottom + margin_top;
slides_per_view.value = Number(data_source_carousel_col);
} else {
// 商品数量大于列数的时候,高度是列数,否则是当前的数量
const col = data_source_content_list.value.length > Number(data_source_carousel_col) ? Number(data_source_carousel_col) : data_source_content_list.value.length;
slides_per_view.value = col;
swiper_height.value = (props.dataHeight * custom_scale.value + padding_top + padding_bottom + margin_bottom + margin_top) * col + ((data_source_carousel_col - 1) * space_between.value);
}
dot_list.value = Array(num);

View File

@ -169,9 +169,6 @@ watchEffect(() => {
const data_source_carousel_col = Number(form.value.data_source_carousel_col);
// 判断是平移还是整屏滚动
slides_per_group.value = new_style.value.rolling_fashion == 'translation' ? 1 : Number(data_source_carousel_col);
// 商品数量大于列数的时候,高度是列数,否则是当前的数量
const col = data_source_content_list.value.length > Number(data_source_carousel_col) ? Number(data_source_carousel_col) : data_source_content_list.value.length;
slides_per_view.value = col;
let num = 0;
// 轮播图数量
if (!isEmpty(data_source_content_list.value)) {
@ -181,8 +178,12 @@ watchEffect(() => {
// 轮播图高度控制
if (form.value.data_source_direction == 'horizontal') {
swiper_height.value = form.value.height * scale.value + padding_top + padding_bottom + margin_bottom + margin_top;
slides_per_view.value = Number(data_source_carousel_col);
} else {
// 商品数量大于列数的时候,高度是列数,否则是当前的数量
const col = data_source_content_list.value.length > Number(data_source_carousel_col) ? Number(data_source_carousel_col) : data_source_content_list.value.length;
swiper_height.value = (form.value.height * scale.value + padding_top + padding_bottom + margin_bottom + margin_top) * col + ((data_source_carousel_col - 1) * space_between.value);
slides_per_view.value = col;
}
dot_list.value = Array(num);
// 更新轮播图的key确保更换时能重新更新轮播图