目录js获取Promise对象里面的值获取Promise{<pending>}的值问题解决总结JS获取Promise对象里面的值 1、以下代码返回值为: const res =
1、以下代码返回值为:
const res = getTaskItems({});
if (res.code === 0) {
this.taskItem = res.data;
}
2、使用一下代码即可获取data里面的值
getTaskItems({}).then(res => {
console.log(res.data);
})
我使用如下代码
let lyric = getLyric(this.$store.state.songId);
console.log(lyric)
获取到的结果:
如果直接console.log(lyric.data),会输出undefined
let lyric = getLyric(this.$store.state.songId);
let a = lyric.then((res)=>{
console.log(res.data)
});
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: JS获取Promise对象里面的值问题
本文链接: https://www.lsjlt.com/news/178308.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0