轮播添加节流处理, 避免一秒内多次操作
parent
d5af5ebbeb
commit
7df517fab7
|
|
@ -48,7 +48,7 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { common_styles_computer, radius_computer, get_math } from '@/utils';
|
||||
import { isEmpty, cloneDeep } from 'lodash';
|
||||
import { isEmpty, cloneDeep, throttle } from 'lodash';
|
||||
import { Swiper, SwiperSlide } from 'swiper/vue';
|
||||
import { Autoplay, EffectCoverflow } from 'swiper/modules';
|
||||
import 'swiper/css';
|
||||
|
|
@ -164,7 +164,10 @@ watchEffect(() => {
|
|||
length: carousel_length
|
||||
};
|
||||
// 更新轮播图的key,确保更换时能重新更新轮播图
|
||||
carouselKey.value = get_math();
|
||||
// 添加节流处理,一秒只执行一次
|
||||
throttle(() => {
|
||||
carouselKey.value = get_math();
|
||||
}, 1000);
|
||||
}
|
||||
//#endregion
|
||||
});
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { common_styles_computer, get_math, gradient_handle, padding_computer, radius_computer } from '@/utils';
|
||||
import { isEmpty, cloneDeep } from 'lodash';
|
||||
import { isEmpty, cloneDeep, throttle } from 'lodash';
|
||||
import ShopAPI from '@/api/shop';
|
||||
|
||||
const props = defineProps({
|
||||
|
|
@ -449,7 +449,10 @@ watchEffect(() => {
|
|||
notice_length: notice_length,
|
||||
};
|
||||
// 更新轮播图的key,确保更换时能重新更新轮播图
|
||||
carouselKey.value = get_math();
|
||||
// 添加节流处理,一秒只执行一次
|
||||
throttle(() => {
|
||||
carouselKey.value = get_math();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { common_styles_computer, radius_computer, get_math } from '@/utils';
|
||||
import { isEmpty, cloneDeep } from 'lodash';
|
||||
import { isEmpty, cloneDeep, throttle } from 'lodash';
|
||||
|
||||
const props = defineProps({
|
||||
value: {
|
||||
|
|
@ -141,7 +141,10 @@ watch(props.value, (val) => {
|
|||
is_roll: display_is_roll,
|
||||
};
|
||||
// 更新轮播图的key,确保更换时能重新更新轮播图
|
||||
carouselKey.value = get_math();
|
||||
// 添加节流处理,一秒只执行一次
|
||||
throttle(() => {
|
||||
carouselKey.value = get_math();
|
||||
}, 1000);
|
||||
}
|
||||
nextTick(() => {
|
||||
if (!isEmpty(bannerImg.value)) {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { background_computer, common_styles_computer, get_math, gradient_computer, gradient_handle, radius_computer } from '@/utils';
|
||||
import { isEmpty, cloneDeep } from 'lodash';
|
||||
import { isEmpty, cloneDeep, throttle } from 'lodash';
|
||||
|
||||
const props = defineProps({
|
||||
value: {
|
||||
|
|
@ -134,7 +134,10 @@ watchEffect(() => {
|
|||
notice_length: notice_length
|
||||
};
|
||||
// 更新轮播图的key,确保更换时能重新更新轮播图
|
||||
carouselKey.value = get_math();
|
||||
// 添加节流处理,一秒只执行一次
|
||||
throttle(() => {
|
||||
carouselKey.value = get_math();
|
||||
}, 1000);
|
||||
}
|
||||
//#endregion
|
||||
});
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { background_computer, common_styles_computer, get_math, gradient_computer, gradient_handle, padding_computer, radius_computer } from '@/utils';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { isEmpty, throttle } from 'lodash';
|
||||
import SeckillAPI from '@/api/seckill';
|
||||
import { online_url } from '@/utils';
|
||||
import { Swiper, SwiperSlide } from 'swiper/vue';
|
||||
|
|
@ -434,7 +434,10 @@ watchEffect(() => {
|
|||
// 判断是平移还是整屏滚动
|
||||
slides_per_group.value = new_style.value.rolling_fashion == 'translation' ? 1 : form.value.carousel_col;
|
||||
// 更新轮播图的key,确保更换时能重新更新轮播图
|
||||
carouselKey.value = get_math();
|
||||
// 添加节流处理,一秒只执行一次
|
||||
throttle(() => {
|
||||
carouselKey.value = get_math();
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
//容器高度
|
||||
|
|
|
|||
Loading…
Reference in New Issue