如何使setTimeout函数同步?

时间:2019-11-08 14:39:51

标签: javascript

我的代码输出(行之间有延迟):

one
three
((2 seconds delay))
two

如何使代码同步,以便显示输出:

one
((2 seconds delay))
two
three

代码:

console.log('one'); 
setTimeout(() => {
    console.log('two');
}, 2000);
console.log('three');

1 个答案:

答案 0 :(得分:1)

[TestFixture]
    public class ValidatePDF
    {
        public NUnit.Framework.TestContext TestContext { get; set; }
 [SetUp]
        public void Init()
        {
           string t = TestContext.TestDirectory;
        }
}