vuexgetters:{getTest:state=>{returnasync()=>{constresult=awaitnewPromise((resolve,reject)=>{setTimeout(function(){resolve('foo');},3000);})returnresult}}}控制台运行vue.$store.getters.getTest()//Promise {}//我希望他返回`foo`希望大佬帮我指正代码,十分感谢!
2 回答
holdtom
TA贡献1805条经验 获得超10个赞
getTest:state=>{returnnewPromise((resolve,reject)=>{setTimeout(()=>{resolve('foo');},3000);});},(async()=>{constresult=awaitthis.$store.getters.getTest;console.log(result);//foo})();
添加回答
举报
0/150
提交
取消