【问题标题】:Staticfile error when using Ob and reflex to import CSS-file使用 Ob 和 reflex 导入 CSS 文件时出现静态文件错误
【发布时间】:2019-08-18 20:43:56
【问题描述】:

我想使用 Obelisk 让两个 div 并排浮动。为此,我已经问过这个问题(Where to put the css file when using obelisk)。这提供了我应该将我的东西放在静态中并添加静态@filename 的答案。但是,这种方法会导致错误。

您可以在下面看到 frontend/src/Frontend.hs 中使用的前端函数的最小示例。

frontend :: Frontend (R FrontendRoute)
frontend = Frontend
    { _frontend_head = prerender_ (text "Loading..") headElement
    , _frontend_body = prerender_ (text "Loading...") bodyElement
    }

headElement :: MonadWidget t m => m ()
headElement = do
    el "title" $ text "Title"
    styleSheet $ static @"/css/cssTest.css"
        where
            styleSheet link = elAttr "link" (Map.fromList [
                    ("rel", "stylesheet"),
                    ("type", "text/css"),
                    ("href", link)
                ]) $ return ()

bodyElement :: MonadWidget t m => m ()
bodyElement = elClass "div" "container" $ do
    elClass "div" "fixed" $ do
        el "h2" $ text "Button enabled / disabled"
    elClass "div" "flex-item" $ do
        el "h2" $ text "Second paragraph next to it."

给出了以下错误消息: 无法推断 (StaticFile "css/cssTest.css") 由使用 'static' 引起。

【问题讨论】:

    标签: css haskell reflex reflex-dom


    【解决方案1】:

    在我从 "/css/cssTest.css" 中删除前导 / 并重新启动 ob run(假设您将文件放在 static/css/cssTest.css)之后,这对我有用。

    【讨论】:

      猜你喜欢
      • 2016-06-11
      • 2019-01-23
      • 2020-01-14
      • 1970-01-01
      • 2021-11-03
      • 2021-07-19
      • 2019-04-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多