diff --git a/src/components/model-nav-group/index.vue b/src/components/model-nav-group/index.vue index 6b2c933e..c29a05be 100644 --- a/src/components/model-nav-group/index.vue +++ b/src/components/model-nav-group/index.vue @@ -13,14 +13,15 @@ -
+
@@ -58,7 +59,7 @@ const text_style = computed(() => `font-size: ${new_style.value.title_size || 12 const indicator_style = computed(() => { let indicator_styles = ''; if (!isEmpty(new_style.value.indicator_radius)) { - indicator_styles += radius_computer(new_style.value.indicator_radius) + indicator_styles += radius_computer(new_style.value.indicator_radius); } const size = new_style.value?.indicator_size || 5; if (new_style.value.indicator_style == 'num') { @@ -75,7 +76,7 @@ const indicator_style = computed(() => { }); // 获取轮播图片的节点 const bannerImg = ref(); -// 轮播图自适应高度 +// 轮播图自适应高度 const newHeight = ref('100px'); // 轮播图定时显示 const interval_time = ref(2000); @@ -91,16 +92,16 @@ const actived_color = computed(() => new_style.value?.actived_color || '#2A94FF' const interval_list = ref({ time: 2000, is_roll: '0', -}) +}); //监听屏幕缩放事件 onMounted(() => { window.onresize = () => { newHeight.value = bannerImg.value[0].clientHeight + 'px'; - } + }; }); // 每个导航所占位置 -const group_width = computed(() => `${100 / (form.value.single_line || 4)}%`); +const group_width = computed(() => `${100 / (form.value.single_line || 4)}%`); // 是否显示文字和图片 const nav_style = computed(() => form.value?.nav_style || 'image_with_text'); @@ -123,52 +124,56 @@ const nav_content_list = computed(() => { // 否则的话,就返回全部的信息 return [{ split_list: list }]; } -}) +}); // 内容参数的集合 -watch(props.value, (val) => { - const new_style = val.style; - const form = val.content; - //#region 轮播图设置 - const time = (new_style.interval_time || 2) * 1000; - const display_is_roll = form.display_style == 'slide' ? new_style.is_roll || true : new_style.is_roll || false; - // 判断跟历史的是否相等,不相等更新组件时间 - if (interval_list.value.time != time || interval_list.value.is_roll != display_is_roll) { - // 滚动时间 - interval_time.value = time; - // 是否滚动 - is_roll.value = display_is_roll == '1' ? true : false; - // 记录历史保存的时间 - interval_list.value = { - time: time, - is_roll: display_is_roll, - }; - // 更新轮播图的key,确保更换时能重新更新轮播图 - carouselKey.value = get_math(); - } - nextTick(() => { - if (!isEmpty(bannerImg.value)) { - newHeight.value = (bannerImg.value[0]?.clientHeight || 100) + 'px'; +watch( + props.value, + (val) => { + const new_style = val.style; + const form = val.content; + //#region 轮播图设置 + const time = (new_style.interval_time || 2) * 1000; + const display_is_roll = form.display_style == 'slide' ? new_style.is_roll || true : new_style.is_roll || false; + // 判断跟历史的是否相等,不相等更新组件时间 + if (interval_list.value.time != time || interval_list.value.is_roll != display_is_roll) { + // 滚动时间 + interval_time.value = time; + // 是否滚动 + is_roll.value = display_is_roll == '1' ? true : false; + // 记录历史保存的时间 + interval_list.value = { + time: time, + is_roll: display_is_roll, + }; + // 更新轮播图的key,确保更换时能重新更新轮播图 + carouselKey.value = get_math(); } - }); - //#endregion -}, {immediate: true, deep: true}); + nextTick(() => { + if (!isEmpty(bannerImg.value)) { + newHeight.value = (bannerImg.value[0]?.clientHeight || 100) + 'px'; + } + }); + //#endregion + }, + { immediate: true, deep: true } +); const carousel_change = (index: number) => { actived_index.value = index; -} +};