【问题】js 之 await ~

	let index = 0

	async function gen(){
		await Promise.resolve('gne1===')
		console.log('gne1===========================================' + index)
		await Promise.resolve('gne2===')
		console.log('gne2===========================================' + index)
		await Promise.resolve('gne3===')
		console.log('gne3===========================================' + index)

	}

	gen()

	Promise.resolve("******").then((x)=>{
		console.log('p1===========================================' + index++ +"====="+x)
		return Promise.resolve("then1retrun")
		// return "then1retrun"
	}).then((x)=>{
		console.log('p2===========================================' + index++ +"====="+x)
		return "then2retrun"
	}).then((x)=>{
		console.log('p3===========================================' + index++ +"====="+x)
		return "then3retrun"
	}).then((x)=>{
		console.log('p4===========================================' + index++ +"====="+x)
		return "then4retrun"
	}).then((x)=>{
		console.log('p5===========================================' + index++ +"====="+x)
		return "then5retrun"
	}).then((x)=>{
		console.log('p6===========================================' + index++ +"====="+x)
		return "then6retrun"
	}).then((x)=>{
		console.log('p7===========================================' + index++ +"====="+x)
		return "then7retrun"
	}).then((x)=>{
		console.log('p8===========================================' + index++ +"====="+x)
		return "then8retrun"
	}).then((x)=>{
		console.log('p9===========================================' + index++ +"====="+x)
		return "then9retrun"
	})

运行结果

其实 还是不太懂

发布了64 篇原创文章 · 获赞 7 · 访问量 6674

猜你喜欢

转载自blog.csdn.net/MENGCHIXIANZI/article/details/105569850