zoukankan      html  css  js  c++  java
  • 饿了么

    代码

    ratingsshow() {
    			 
    					if (this.rating === true) {
    					let
    					 text = this.food.ratings.filter((rating) => {
    							if (this.ratingType === 0) {return rating.text && rating}
    
    
    else if (this.ratingType === 1) {return  rating.text && rating.rateType === 0} 
    else if (this.ratingType === 2) {return rating.text && rating.rateType === 1} 
    						})
    						
    						return text
    
    				} else {
    					let text = this.food.ratings.filter((rating) => {
    							if (this.ratingType === 0) {
    								return rating
    
    							} else if (this.ratingType === 1) {
    								return rating.rateType === 0
    							} else if (this.ratingType === 2) {
    								return  rating.rateType === 1
    							}
    
    						})
    						return text
    					}
    				 
    				
    				}
    

      vue数据是异步加载的,此时this.food.ratings还没有加载

    可以加个判断

    ratingsshow() {
    				if(this.food.ratings){
    					if (this.rating === true) {
    					let
    					 text = this.food.ratings.filter((rating) => {
    							if (this.ratingType === 0) {return rating.text && rating}
    
    
    else if (this.ratingType === 1) {return  rating.text && rating.rateType === 0} 
    else if (this.ratingType === 2) {return rating.text && rating.rateType === 1} 
    						})
    						
    						return text
    
    				} else {
    					let text = this.food.ratings.filter((rating) => {
    							if (this.ratingType === 0) {
    								return rating
    
    							} else if (this.ratingType === 1) {
    								return rating.rateType === 0
    							} else if (this.ratingType === 2) {
    								return  rating.rateType === 1
    							}
    
    						})
    						return text
    					}
    				} 
    				
    				}
    

      ok

  • 相关阅读:
    System.Collections.Generic.IEnumerable.cs
    System.Collections.IList.cs
    茶-保健茶:松针茶
    中药-中药名:松针
    植物:松树
    LDAP-常用命令
    dsadm-dsconf数据导入导出
    SUN-LDAP6.3_RHEL 5.0-卸载LDAP
    passwd-shadow文件
    文件及目录的权限
  • 原文地址:https://www.cnblogs.com/chargeworld/p/10356099.html
Copyright © 2011-2022 走看看