如何使用Suave web的CSS

时间:2017-12-19 08:43:27

标签: css f# suave

我是新手F#编程,

现在我尝试用F#和Suave制作网页,然后我从this link

开始

我有一个问题,我不能在我的项目中使用css(参见图片)

id="box" wasn't show on browser

文件View.fs

let index container =
html [] [
    head [] [
        title [] "Suave Music Store"
        cssLink "/Site.css"
    ]

    body [] [
        div ["id", "header"] [
            tag "h1" [] [
                a Path.home [] [Text "F# Suave Music Store"]
            ]
        ]

        div ["id", "main"] [
            div ["id", "box"] [
                a Path.Store.browse [] [Text "Test Link"]
                tag "h1" [] [
                    a "http://www.google.com" [] [Text "Google"]
                ]
            ]
        ]
        div ["id", "footer"] [
            Text "built with "
            a "http://fsharp.org" [] [Text "F#"]
            Text " and "
            a "http://suave.io" [] [Text "Suave.IO"]
        ]
    ]
]
|> htmlToString
文件Site.css中的

和#box

#box
{
    border:4px solid #000;
}

我怎么能解决它?

1 个答案:

答案 0 :(得分:2)

这可能是一个缓存问题 - 如果您要更改CSS文件并且浏览器缓存旧版本,则服务器上的最新更改可能不可见。

您可以配置浏览器以避免缓存。或者,您可以更改服务器以发送禁用缓存的HTTP标头(在开发和调试期间):

let noCache =
  Writers.setHeader "Cache-Control" "no-cache, no-store, must-revalidate"
  >>= Writers.setHeader "Pragma" "no-cache"
  >>= Writers.setHeader "Expires" "0"

// And then in your main handler add 'noCache'
pathRegex "(.*)\.(css|png)" >=> noCache >=> Files.browseHome