Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F# 如何让用户下载寓言中的文件?_F#_Fable F#_Elmish - Fatal编程技术网

F# 如何让用户下载寓言中的文件?

F# 如何让用户下载寓言中的文件?,f#,fable-f#,elmish,F#,Fable F#,Elmish,我有一个安全堆栈应用程序。我需要使用户能够上传和下载文件 利用 Browser.Dom.FileReader.Create() 是否有相应的方法让用户下载文件 提供了一个使用完全不同的机制的解决方案,该机制依赖于js库。是否没有与文件阅读器方法相对应的机制?我提出了以下似乎对我有效的方法 let downLoad fileName fileContent = let anchor = Browser.Dom.document.createElement "a"

我有一个安全堆栈应用程序。我需要使用户能够上传和下载文件

利用

Browser.Dom.FileReader.Create()
是否有相应的方法让用户下载文件


提供了一个使用完全不同的机制的解决方案,该机制依赖于js库。是否没有与
文件阅读器
方法相对应的机制?

我提出了以下似乎对我有效的方法

let downLoad fileName fileContent =
    let anchor = Browser.Dom.document.createElement "a"
    let encodedContent = fileContent |> sprintf "data:text/plain;charset=utf-8,%s" |> Fable.Core.JS.encodeURI
    anchor.setAttribute("href",  encodedContent)
    anchor.setAttribute("download", fileName)
    anchor.click()