Skip to content

Commit e89c339

Browse files
committed
fix bug of icon_name
1 parent 8330271 commit e89c339

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/page/shop/shop.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@
104104
<h3 class="food_description_head">
105105
<strong class="description_foodname">{{foods.name}}</strong>
106106
<ul v-if="foods.attributes.length" class="attributes_ul">
107-
<li v-for="(attribute, foodindex) in foods.attributes" :key="foodindex" :style="{color: '#' + attribute.icon_color,borderColor:'#' +attribute.icon_color}" :class="{attribute_new: attribute.icon_name == '新'}">
108-
<p :style="{color: attribute.icon_name == '新'? '#fff' : '#' + attribute.icon_color}">{{attribute.icon_name == '新'? '新品':attribute.icon_name}}</p>
107+
<li v-if="attribute" v-for="(attribute, foodindex) in foods.attributes" :key="foodindex" :style="{color: '#' + attribute.icon_color,borderColor:'#' + attribute.icon_color}" :class="{attribute_new: attribute.icon_name == '新'}">
108+
<p :style="{color: attribute.icon_name == '新'? '#fff' : '#' + attribute.icon_color}">{{attribute.icon_name == '新'? '新品':attribute.icon_name}}</p>
109109
</li>
110110
</ul>
111111

@@ -448,11 +448,13 @@
448448
//获取食品列表的高度,存入shopListTop
449449
getFoodListHeight(){
450450
const listContainer = this.$refs.menuFoodList;
451-
const listArr = Array.from(listContainer.children[0].children);
452-
listArr.forEach((item, index) => {
453-
this.shopListTop[index] = item.offsetTop;
454-
});
455-
this.listenScroll(listContainer)
451+
if (listContainer) {
452+
const listArr = Array.from(listContainer.children[0].children);
453+
listArr.forEach((item, index) => {
454+
this.shopListTop[index] = item.offsetTop;
455+
});
456+
this.listenScroll(listContainer)
457+
}
456458
},
457459
//当滑动食品列表时,监听其scrollTop值来设置对应的食品列表标题的样式
458460
listenScroll(element){
@@ -471,7 +473,7 @@
471473
const wrapMenuHeight = this.$refs.wrapperMenu.clientHeight;
472474
this.foodScroll.on('scroll', (pos) => {
473475
if (!this.$refs.wrapperMenu) {
474-
return
476+
return
475477
}
476478
this.shopListTop.forEach((item, index) => {
477479
if (this.menuIndexChange && Math.abs(Math.round(pos.y)) >= item) {
@@ -1053,6 +1055,7 @@
10531055
@include sc(.4rem, #fff);
10541056
text-align: center;
10551057
flex: 1;
1058+
transform: scale(0.8) translate(0.1rem, -.1rem);
10561059
}
10571060
}
10581061
}

0 commit comments

Comments
 (0)