When a custom method invokes a component in Javascript, you need to wait before the result is returned.

when customizing the method, you need to determine whether there is a file locally, so you need to call the getFileInfo method, and then process the file

.
function getLocalIcon(name) {
  let iconPath = "../images/category_ico/";
  let tail = ".png";
  var link = iconPath + name + tail;
  var ret = "";
  wx.getFileInfo({
    filePath: link,
    success: function (data) {
      ret = link;
    },
    fail: function (data) {
      ret = hosts + "icon/" + name + tail;
    },
    complete: function(){
      console.log(ret);   //
      return ret;
    }
  })
  return ret;
}

call method

icon = parseInt(bean.icon) == 0 ? wxLink.getLocalIcon(bean.img_url) : wxLink.getImgLink(bean.img_url,"icon");

console.log(icon)   //

print order is print two print one.
executes the wx.getFielInfo method when the method getLocalIcon is called, but when executing the wx.getFielInfo result, it returns the great gods of ret, who want to consult the forum. How to set the wait to let the result pause return first when calling wx.getFieldInfo?

Menu