function * gen () { let result = yield axios.get('https://api.github.com/users/github') console.log(result.bio) } let g = gen() g.next().value.then(v=>{ return JSON.stringify(v) }).then((data)=>{ let blob = new Blob([data]) blobUrl = window.URL.createObjectURL(blob) const a = document.createElement('a') document.querySelector('#container').appendChild(a) a.download='新建文件名.txt' a.innerHTML = 'clickme' a.href = blobUrl })