1

これは、O reilly - Yesod - Widgetsのコード スニペットです。

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 には、モジュール名を検索して自動インポートしようとする自動補完機能がありますか?

4

1 に答える 1

2

インポートYesod.CoreおよびYesod.Core.Widget、それらは適切な機能を提供します。

また、彼らは本のオンライン版を持っていることに注意してください. 通常、インポート エラーが発生した場合は、Hoogle で検索してください。ほとんどの場合、そこで解決策が見つかる可能性があります。

于 2015-05-02T16:44:25.280 に答える