async和await的的基本使用
【代码】async和await的的基本使用。
·
async和await的的基本使用
示例
import thenFs from "then-fs"
async function getAllFile(){
const r1 = await thenFs.readFile('./files/1.txt','utf8')
console.log(r1)
const r2 = await thenFs.readFile('./files/2.txt','utf8')
console.log(r2)
const r3 = await thenFs.readFile('./files/3.txt','utf8')
console.log(r3)
}
getAllFile()
说明:
await’ expressions are only allowed within async functions and at the top levels of modules.ts(1308)
更多推荐




所有评论(0)