hookehuyr

首页高度自适应

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