get it to run
This commit is contained in:
parent
b1afd45d41
commit
bd3a93d628
@ -15,6 +15,9 @@ fsharp_space_before_uppercase_invocation = true
|
||||
[*.{fs,fsx,fsi}]
|
||||
fsharp_bar_before_discriminated_union_declaration = true
|
||||
max_line_length = 120
|
||||
fsharp_array_or_list_multiline_formatter = number_of_items
|
||||
fsharp_max_array_or_list_number_of_items = 4
|
||||
fsharp_max_function_binding_width=0
|
||||
|
||||
# C# files
|
||||
[*.cs]
|
||||
|
||||
21
Client.fs
21
Client.fs
@ -4,27 +4,14 @@ open WebSharper
|
||||
open WebSharper.JavaScript
|
||||
open WebSharper.UI
|
||||
open WebSharper.UI.Client
|
||||
open WebSharper.UI.Html
|
||||
open WebSharper.UI.Templating
|
||||
|
||||
[<JavaScript>]
|
||||
module Client =
|
||||
// The templates are loaded from the DOM, so you just can edit index.html
|
||||
// and refresh your browser, no need to recompile unless you add or remove holes.
|
||||
type IndexTemplate = Template<"wwwroot/index.html", ClientLoad.FromDocument>
|
||||
|
||||
let People = ListModel.FromSeq [ "John"; "Paul" ]
|
||||
|
||||
|
||||
[<SPAEntryPoint>]
|
||||
let Main () =
|
||||
let newName = Var.Create ""
|
||||
|
||||
IndexTemplate
|
||||
.Main()
|
||||
.ListContainer(People.View.DocSeqCached (fun (name: string) -> IndexTemplate.ListItem().Name(name).Doc ()))
|
||||
.Name(newName)
|
||||
.Add(fun _ ->
|
||||
People.Add newName.Value
|
||||
newName.Value <- "")
|
||||
.Doc ()
|
||||
div [] [
|
||||
p [] [ text "hello world" ]
|
||||
]
|
||||
|> Doc.RunById "main"
|
||||
|
||||
@ -8,10 +8,13 @@ open web_api_cookbook
|
||||
|
||||
[<EntryPoint>]
|
||||
let main args =
|
||||
let builder = WebApplication.CreateBuilder (args)
|
||||
let builder = WebApplication.CreateBuilder args
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddWebSharper().AddAuthentication("WebSharper").AddCookie ("WebSharper", fun options -> ())
|
||||
builder.Services
|
||||
.AddWebSharper()
|
||||
.AddAuthentication("WebSharper")
|
||||
.AddCookie ("WebSharper", fun options -> ())
|
||||
|> ignore
|
||||
|
||||
let app = builder.Build ()
|
||||
@ -27,7 +30,7 @@ let main args =
|
||||
app
|
||||
.UseHttpsRedirection()
|
||||
#if DEBUG
|
||||
.UseWebSharperScriptRedirect(startVite = true)
|
||||
// .UseWebSharperScriptRedirect(startVite = true)
|
||||
#endif
|
||||
.UseDefaultFiles()
|
||||
.UseStaticFiles()
|
||||
|
||||
@ -5,23 +5,10 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" type="text/css" href="Scripts/web_api_cookbook.css" />
|
||||
<style>
|
||||
/* Don't show the not-yet-loaded templates */
|
||||
[ws-template], [ws-children-template] { display: none; }
|
||||
</style>
|
||||
<script type="text/javascript" src="Scripts/web_api_cookbook.head.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>My list of unique people</h1>
|
||||
<div id="main" ws-children-template="Main">
|
||||
<ul ws-hole="ListContainer">
|
||||
<li ws-template="ListItem">${Name}</li>
|
||||
</ul>
|
||||
<div>
|
||||
<input ws-var="Name" placeholder="Name" />
|
||||
<button ws-onclick="Add">Add</button>
|
||||
<div>You are about to add: ${Name}</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
</div>
|
||||
<script type="module" src="Scripts/web_api_cookbook.min.js"></script>
|
||||
</body>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user