[英]Can we call non-async function from async function?
從函數方法調用非異步函數時遇到問題。 有沒有辦法做到這一點?
例:
async function myMethod()
{
console.log('In async method');
nonasyncmethod();
}
function nonasyncmethod()
{
console.log('In non-async method');
}
是的,你可以從內部調用異步和同步功能async
功能-他們沒有將所有異步(當然對於具有的主要原因async
函數是一個異步功能,但它們具有同步功能以及工作):
async function myMethod() { console.log('In async method'); nonasyncmethod(); } function nonasyncmethod() { console.log('In non-async method'); } myMethod();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.