|
104 | 104 | <h3 class="food_description_head">
|
105 | 105 | <strong class="description_foodname">{{foods.name}}</strong>
|
106 | 106 | <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> |
109 | 109 | </li>
|
110 | 110 | </ul>
|
111 | 111 |
|
|
448 | 448 | //获取食品列表的高度,存入shopListTop
|
449 | 449 | getFoodListHeight(){
|
450 | 450 | 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 | + } |
456 | 458 | },
|
457 | 459 | //当滑动食品列表时,监听其scrollTop值来设置对应的食品列表标题的样式
|
458 | 460 | listenScroll(element){
|
|
471 | 473 | const wrapMenuHeight = this.$refs.wrapperMenu.clientHeight;
|
472 | 474 | this.foodScroll.on('scroll', (pos) => {
|
473 | 475 | if (!this.$refs.wrapperMenu) {
|
474 |
| - return |
| 476 | + return |
475 | 477 | }
|
476 | 478 | this.shopListTop.forEach((item, index) => {
|
477 | 479 | if (this.menuIndexChange && Math.abs(Math.round(pos.y)) >= item) {
|
|
1053 | 1055 | @include sc(.4rem, #fff);
|
1054 | 1056 | text-align: center;
|
1055 | 1057 | flex: 1;
|
| 1058 | + transform: scale(0.8) translate(0.1rem, -.1rem); |
1056 | 1059 | }
|
1057 | 1060 | }
|
1058 | 1061 | }
|
|
0 commit comments