hookehuyr

移动端产品优势只有一条数据时,显示优化

1 <!-- 1 <!--
2 * @Date: 2024-09-29 14:26:41 2 * @Date: 2024-09-29 14:26:41
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-11-05 10:15:08 4 + * @LastEditTime: 2024-11-05 10:27:39
5 * @FilePath: /hager/src/views/product/detail.vue 5 * @FilePath: /hager/src/views/product/detail.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -362,6 +362,9 @@ export default { ...@@ -362,6 +362,9 @@ export default {
362 return result; 362 return result;
363 }, 363 },
364 splitIntoEqualChunks(list) { 364 splitIntoEqualChunks(list) {
365 + if (this.is_xs && list.length === 1) { // 移动端只有一个元素,直接返回一个包含该元素的数组
366 + return [list]
367 + }
365 const middle = Math.ceil(list.length / 2); // 计算数组的一半,向上取整 368 const middle = Math.ceil(list.length / 2); // 计算数组的一半,向上取整
366 const result = []; 369 const result = [];
367 370
......