我的组件加载良好,但样式没有加载,事件也没有触发。我正在跟踪文档,没有错误被抛出,但似乎我在这里可能遗漏了一些基本的东西?
用res.marko呈现的视图模板
import Explanation from "./components/explanation.marko";
<!DOCTYPE html>
<html lang="en">
<head>
...
</head>
<body>
...
<include(Explanation, input.explanation) />
...
</body>
</html>explanation.marko file
class {
onExplanationClick() {
console.log("Explanation clicked");
}
}
style {
.explanation-paragraph {
color: red;
}
}
<div id="explanation" on-click('onExplanationClick')>
<for (paragraph in input.content)>
<p class="explanation-paragraph">${paragraph}</p>
</for>
</div>服务器端:
app.get("/explanation/:id", async function(req, res) {
var explanation = await findExplanation(req.params.id);
var template = require("../../views/explanation/explanation.marko");
res.marko(template, { explanation, user: req.user });
});也可以使用marko/node-require和marko/express。
发布于 2017-10-20 16:56:10
您将需要集成一个模块绑定器/资产管道。在示例马科特快应用程序中,我们使用的是套索 (资产管道+ JavaScript模块绑定程序)。
还有另一个集成Webpack的示例应用程序:https://github.com/marko-js-samples/marko-webpack
马科团队支持拉索和Webpack,但我们推荐拉索,因为它更简单,需要最少的配置。
请看一下marko-express应用程序,如果你被卡住了,可以在我们的Gitter聊天室问问题:https://gitter.im/marko-js/marko
https://stackoverflow.com/questions/46833550
复制相似问题