简体   繁体   中英

How do i apply both hard-coded and method classes in Elmish?

I am formatting a web application made using F# and the SAFE stack. I am using a variable to determine a CSS class to change the formatting of a tag, but I also need two hard-coded CSS classes, and I am unsure how to have both.

I have this:

let statusTag (state:Appointment.State) =
    span [ Class (state.ToString()) ] [ str (sprintf "%A" state) ]

And i need it to work more like this:

let statusTag (state:Appointment.State) =
    span [ Class "status text" + (state.ToString()) ] [ str (sprintf "%A" state) ]

But i dont know how to do this in F#

Any help would be appreciated

The only thing that seems wrong with your attempt is that you need extra parentheses around the expression that constructs the string with the names of the classes (on the other hand, you do not need it around the state.ToString() call). The following should do the trick:

let statusTag (state:Appointment.State) =
    span [ Class("status text" + state.ToString()) ] [ str (sprintf "%A" state) ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM