Websharper を使用してユーザー入力を収集するフォームを作成しようとしています。これまでのところ、サイトの 3 つのアクションを特定しました。
type MyAction =
| [<CompiledName "">] Index
| [<Method "POST">] GetUser of username : string
| Stats of username: string
Sitelet.Infer を使用して基本的な UI を実装できましたが、入力ボックス (usernameInput) の内容を参照する方法がわかりません。
Sitelet.Infer <| function
| Index ->
Content.PageContent <| fun ctx ->
let usernameInput= Input [Text ""]
{ Page.Default with
Title = Some "Welcome!"
Body =
[
Div [
Form
[
usernameInput-< [Name "username" ]
Input [Value "Request"] -< [Type "submit" ]
] -< [ Attr.Action (ctx.Link (* GetUser usernameInput.Content *) ); Method "POST" ]
]
]
}
| GetUser username ->
Content.Redirect <| Stats username
| Stats username ->
Content.PageContent <| fun ctx ->
{ Page.Default with
Body = [Text ("Stats for " + username)] }
usernameInput に「Value」などのフィールドがないことに気付きました。キャストが必要か、何か間違っていると思います。
コードで JavaScript を使用したくないのですが (サイトレットで Html.Server 要素と Html.Client 要素を混在させることはできますか?)。