0
我定義DU的各種類的支持我使用HTML中:F#3 WebSharper
type Class =
| Logo
| Screen
| Continue
現在不幸的是FSharpValue.GetUnionFields
不轉化爲JS(我不希望它)和壓倒一切DU上的ToString使它轉化爲JS似乎也不起作用。因此,我定義了以下運營商應對來自DOM元素添加/刪除類:
[<JavaScript>]
let getClassString = function
| Logo -> "logo"
| Screen -> "screen"
| Continue -> "continue"
[<JavaScript>]
let inline (|+>) (x : Element) (c : Class) = x.AddClass (getClassString c); x
[<JavaScript>]
let inline (|->) (x : Element) (c : Class) = x.RemoveClass (getClassString c)
,真正使之極樂:
[<JavaScript>]
let mainMenu =
Div [
H2 [Text "Jewel"; Br [] :> _; Text "Warrior"] |+> Logo
[
"Play", gameScreen
"HighScore", highScores
"About", notReady
"Exit", notReady
] |> Seq.map (fun (text, screen) -> LI [Button [Text text] |>! OnClick (fun _ _ -> show screen)])
|> UL |+> Menu
] |+> MainMenu |+> Screen
可能有人證實,F#類型的供應商將是一個很適合直接從CSS生成我的Class DU?
我們可以期待WebSharper與VS11 beta兼容還是僅僅在它發佈時兼容?
謝謝!