javascript - EJS 部分/组件
问题描述
如果我有以下目录结构,是否可以在部分中渲染部分,基本上就像创建一个与反应组件没有不同的视图设置(这就是我的看法)
- server
- views
- partials
- components
component-1.ejs
component-2.ejs
blog.ejs
navbar.ejs
footer.ejs
home.ejs
contact.ejs
因此,在我的主页中,我有一个部分blog.ejs
,而在那个部分中,我想拥有component-1.ejs
我尝试了各种排列,但总是面临错误Error: Could not find the include file
主页.ejs
<div class="example">
<% include partials/blog %>
</div>
博客.ejs
<div class="another-example">
<% include components/component-1 %>
</div>
使用 EJS 可以进行这种渲染吗?
解决方案
推荐阅读
- python - 运行任意 python 代码的 Bokeh hovertools
- django - Django 模型设计建议
- depth-first-search - 图中 DFS 和 BFS 的空间复杂度
- javascript - 谷歌图表上的 ASP.NET MVC 不匹配错误
- r - RSelenium 抓取返回奇怪的结果
- debugging - gdb 错误-“不是可执行格式:文件格式无法识别”
- python - Python 获取随机唯一 N 对
- r - RSelenium:从 Google 搜索中单击 for 循环中的后续链接
- sql-server - SQL Server:图形/层次结构 SQL 结构
- jquery - 使用 jQuery 修剪 itemprop 属性