码迷,mamicode.com
首页 > 其他好文 > 详细

饿了么

时间:2019-02-08 14:27:16      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:mic   没有   height   size   this   src   filter   .text   text   

技术图片

代码

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

 

饿了么

标签:mic   没有   height   size   this   src   filter   .text   text   

原文地址:https://www.cnblogs.com/chargeworld/p/10356099.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!