通过url下载文件。而不是打开文件

```

代码如下,为什么手机写不了markdown,。。。。。。。。。。

```

let url = 'http://127.0.0.1:8080/hhh.json'

let name = url.substring(url.lastIndexOf("/") + 1)

let downLoad = async () => {

  let responsePromise = await fetch(url)

  let blob = await responsePromise.blob()

  let objectURL = window.URL.createObjectURL(blob)

  let a = document.createElement('a')

  a.href = objectURL

  a.download = name

  a.click()

  a.remove()

}

downLoad()

```

你可能感兴趣的:(通过url下载文件。而不是打开文件)