函数return
作者:互联网
findCategory(id) { // this.Category=[{id:1,name:'ljj'},{id:2,name:'wmy'}] var ar = this.Category.find(function (elem) { return elem.id == id; }); return ar.name },
法2
findCategory(id) { var value this.Category.forEach(item => { if (item.id == id) { value = item.name } }) return value },
^(* ̄(oo) ̄)^:foreach不可以内部直接return
异步函数,async/await,promise目前return出的都是[promise object]
标签:Category,return,函数,value,item,id,name 来源: https://www.cnblogs.com/ljingjing/p/16669428.html