return返回没拿到值,async/await

export async function getImgUrl(uuid) {
let path = await getImage(uuid)
return path
}

async function getImage(uuid){
let img= await getUuidImage(uuid)
return img;

}

<el-table-column label="参赛人照片" align="center">

<template slot-scope="scope">
  <img :src="getImageUrl(scope.row.headImg)" width="155px" height="100px"/>
</template>

</el-table-column>

getImageUrl (uuid) {

  return getImgUrl(uuid).then(res => {return res})

},

请问return 返回没拿到值

阅读 3.1k
1 个回答

你return的是一个promise对象,当然没法绑定到src上。可以这样改:

getImageUrl (uuid) {

getImgUrl(uuid).then(res => {this.x=res;);

if (this.x===undefined){

return "";

}

return this.x;

}

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题