使用Ob和Reflex导入CSS文件时出现staticfile错误 [英] Staticfile error when using Ob and reflex to import CSS-file

查看:97
本文介绍了使用Ob和Reflex导入CSS文件时出现staticfile错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用方尖碑并排放置两个div的浮点数.为此,我已经问了这个问题(将CSS文件放在何处使用方尖碑).这提供了答案,我应该将我的东西放在静态文件中并添加静态@filename.但是,这种方法会导致错误.

I want to make two div's float side by side using Obelisk. For this I already asked this question (Where to put the css file when using obelisk). This provided the answer that I should put my stuff in static and add static @filename. However, this approach results in an error.

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

Below you can see a minimal example of the frontend function used in 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")由使用静态"引起.

The following error message was given: Could not deduce (StaticFile "css/cssTest.css") arising from a use of 'static'.

推荐答案

当我从"/css/cssTest.css"中删除开头的/并重新启动ob run(假设您将文件放在static/css/cssTest.css上)后,这对我有用.

This worked for me after I removed the leading / from "/css/cssTest.css" and restarted ob run (assuming you placed the file at static/css/cssTest.css).

这篇关于使用Ob和Reflex导入CSS文件时出现staticfile错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆