hookehuyr

首页高度自适应

1 /* 1 /*
2 * @Date: 2022-07-26 09:49:54 2 * @Date: 2022-07-26 09:49:54
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-21 16:45:53 4 + * @LastEditTime: 2024-10-24 11:02:47
5 * @FilePath: /hager/src/common/mixin.js 5 * @FilePath: /hager/src/common/mixin.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -17,6 +17,8 @@ export default { ...@@ -17,6 +17,8 @@ export default {
17 this.handleResize(); 17 this.handleResize();
18 // 监听窗口的 resize 事件 18 // 监听窗口的 resize 事件
19 window.addEventListener('resize', this.handleResize); 19 window.addEventListener('resize', this.handleResize);
20 + // 高度监听
21 + this.top_img_height = $(window).width()*0.38 + 'px';
20 }, 22 },
21 beforeDestroy() { 23 beforeDestroy() {
22 // 在组件销毁前移除监听器,防止内存泄漏 24 // 在组件销毁前移除监听器,防止内存泄漏
...@@ -41,6 +43,7 @@ export default { ...@@ -41,6 +43,7 @@ export default {
41 } else { 43 } else {
42 this.top_img_height = '38rem'; 44 this.top_img_height = '38rem';
43 } 45 }
46 + this.top_img_height = $(window).width()*0.38 + 'px';
44 }, 47 },
45 }, 48 },
46 directives: { 49 directives: {
......
1 <!-- 1 <!--
2 * @Date: 2024-08-27 10:06:30 2 * @Date: 2024-08-27 10:06:30
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-24 10:52:43 4 + * @LastEditTime: 2024-10-24 11:08:47
5 * @FilePath: /hager/src/views/index.vue 5 * @FilePath: /hager/src/views/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
...@@ -184,6 +184,7 @@ import hagerBox from '@/components/common/hagerBox'; ...@@ -184,6 +184,7 @@ import hagerBox from '@/components/common/hagerBox';
184 import hagerH1 from '@/components/common/hagerH1.vue'; 184 import hagerH1 from '@/components/common/hagerH1.vue';
185 import hagerMore from '@/components/hagerMore.vue'; 185 import hagerMore from '@/components/hagerMore.vue';
186 import { getHomeAPI } from "@/api/hager.js"; 186 import { getHomeAPI } from "@/api/hager.js";
187 +import $ from 'jquery';
187 188
188 export default { 189 export default {
189 mixins: [mixin.init], 190 mixins: [mixin.init],
......