結合promise分析fetch獲取資源

1.fetch獲取資源後,會返回一個promise對象,所以可用then等方法。來進行後續處理,下面是鄙人的一個例子,a.txt文件,是當前目錄下的一個文件 let url = './a.txt'; fetch(url).then(res => { res.text().then(data => { console.log(data); }); }) fetch獲取
相關文章
相關標籤/搜索