Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
hager
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2024-10-24 15:45:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c475d9135258188620488b8514e53c72e3577875
c475d913
1 parent
d1fc3385
首页的产品中心图片展示是正方形
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
src/views/index.vue
src/views/index.vue
View file @
c475d91
<!--
* @Date: 2024-08-27 10:06:30
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-10-24 1
2:51:53
* @LastEditTime: 2024-10-24 1
5:39:51
* @FilePath: /hager/src/views/index.vue
* @Description: 首页
-->
...
...
@@ -102,8 +102,8 @@
<swiper ref="myProductSwiper" class="swiper" :options="swiperOption" @slideChange="onProductSlideChange">
<swiper-slide v-for="(item, index) in product_list" :key="index">
<div @click="goToProduct(item)" class="product-item xs">
<div class="img" :style="{ height:
'8rem'
, backgroundImage: 'url('+item.cover+')' }"></div>
<p style="margin: 0.5rem;">{{ item.category_name }}</p>
<div class="img" :style="{ height:
product_box_height
, backgroundImage: 'url('+item.cover+')' }"></div>
<p
class="product-title"
style="margin: 0.5rem;">{{ item.category_name }}</p>
</div>
</swiper-slide>
</swiper>
...
...
@@ -118,7 +118,7 @@
<i :class="['el-icon-arrow-right', reach_product_end ? 'disabled' : '']" @click="nextProductBtn()"></i>
</div>
</div>
</div>
{{ product_list.length > productSlidesPerView }}/{{ is_xs }}/{{ !isEnd }}
</div>
</div>
</hager-box>
<hager-box v-if="!is_xs" class="box-2n">
...
...
@@ -249,6 +249,7 @@ export default {
reach_product_end: false,
productSlidesPerView: 5,
isEnd: false,
product_box_height: '10rem'
}
},
async mounted () {
...
...
@@ -266,6 +267,14 @@ export default {
this.productSlidesPerView = swiper.slidesPerView;
});
});
// 高度监听
this.$nextTick(() => {
this.product_box_height = $('.product-item').outerWidth() - $('.product-title').outerHeight() + 'px';
})
},
beforeDestroy() {
// 在组件销毁前移除监听器,防止内存泄漏
window.removeEventListener('resize', this.handleHeightResize);
},
watch: {
// 监听$route对象的变化
...
...
@@ -274,6 +283,10 @@ export default {
}
},
methods: {
handleHeightResize () {
// 高度监听
this.product_box_height = $('.product-item').outerWidth() - $('.product-title').outerHeight() + 'px';
},
getToGroup () {
this.$router.push({
path: '/about/global'
...
...
Please
register
or
login
to post a comment