缺少从 Hamlet 库中导入的内容
Missing imports from Hamlet libraries
这是来自 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 是否具有自动完成功能,会尝试搜索并自动导入模块名称?
导入Yesod.Core
和Yesod.Core.Widget
,它们将提供相应的功能。
另请注意,他们有一本 online version 的书。通常,如果您看到导入错误,请在 Hoogle 上进行搜索,在大多数情况下,您很可能会在那里找到解决方案。
这是来自 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 是否具有自动完成功能,会尝试搜索并自动导入模块名称?
导入Yesod.Core
和Yesod.Core.Widget
,它们将提供相应的功能。
另请注意,他们有一本 online version 的书。通常,如果您看到导入错误,请在 Hoogle 上进行搜索,在大多数情况下,您很可能会在那里找到解决方案。