【发布时间】:2019-11-30 19:33:42
【问题描述】:
我使用 Express 和 Handlebars 开始了一个项目,然后被鼓励研究 Vue.js。我仍处于阅读文档的阶段,但到目前为止还无法理解如何在 Vue.js 中拥有布局、部分和部分。我认为部分将是一个组件,但我不知道如何拥有一个可以注入内容的部分和部分的布局。
这就是我在一个名为 baselayout.hbs 的文件中使用 npm express-handlebars 所做的:
<!doctype html>
<html lang="en">
<head>
{{> global/headcode }} <!-- partial view with code for the head tag. it has stuff like favicon links --->
{{{_sections.pagemeta}}} <!-- page specific metadata injected here. this would be meta keywords description etc for a page/view --->
</head>
<body>
<div>
{{> global/siteheader }} <!--- partial view for the site's header --->
<div id="base-Container">
<main id="base-Content" role="main">
{{{ body }}} <!--- a page's main body content goes here --->
</main>
</div>
</div>
{{> sitefooter }}
{{{_sections.pagescripts}}} <!-- section for page-specific scripts injected here --->
</body>
</html>
我怎样才能在 Vue.js 中设置类似上面的东西,也可以用于服务器端渲染?我只需要一个包含页眉/页脚组件的基本布局,还需要页面特定内容可以进入的部分。
【问题讨论】:
标签: javascript node.js vue.js handlebars.js express-handlebars