【问题标题】:Missing imports from Hamlet libraries缺少从 Hamlet 库的导入
【发布时间】:2015-05-02 15:32:07
【问题描述】:

这是来自O reilly - Yesod - Widgets的代码sn-p,

getRootR = defaultLayout $ do
    setTitle "My Page Title"
    toWidget [lucius| h1 { color: green; } |]
    addScriptRemote "https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"
    toWidget [julius|
      $(function() {
        $("h1").click(function(){ alert("You clicked on the heading!"); });
      });
    |]
    toWidgetHead [hamlet| <meta name=keywords content="some sample keywords">|]
    toWidget [hamlet| <h1>Here's one way of including content |]
    [whamlet| <h2>Here's another |]
    toWidgetBody [julius| alert("This is included in the body itself"); |]

此代码产生错误,

widget.hs:3:12: Not in scope: ‘defaultLayout’
widget.hs:4:3: Not in scope: ‘setTitle’
widget.hs:5:3: Not in scope: ‘toWidget’

Hamlet 的模块是什么,我需要导入才能使其工作? haskell 是否有自动完成功能,会尝试搜索和自动导入模块名称?

【问题讨论】:

  • 你导入Yesod.CoreYesod.Core.Widget了吗?
  • 解决了undefined 错误。谢谢,西比

标签: haskell yesod template-haskell hamlet


【解决方案1】:

导入Yesod.CoreYesod.Core.Widget,它们会提供相应的功能。

还要注意他们有本书的online version。通常,如果您看到导入错误,请在 Hoogle 上进行搜索,在大多数情况下,您很可能会在那里找到解决方案。

【讨论】:

    猜你喜欢
    • 2021-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-11
    • 2020-01-07
    • 2021-07-31
    • 2019-12-06
    • 1970-01-01
    相关资源
    最近更新 更多