【发布时间】:2018-01-24 08:46:07
【问题描述】:
我需要在另一个 ejs 文件中调用一个 ejs 文件并且完全在函数中,但我总是“无法获取文件” 如果我在函数之外做一个包含文件。它可以工作。 但是我需要在函数中调用这个ejs文件。
<input type = "submit" value = "heure" id="sub" style="width:120px" onclick="changer()"/>
<input type = "submit" value = "journée" id="sub1" style="width:120px" onclick="changersub1()"/>
<script type="text/javascript">
function changersub1()
{
document.getElementById("sub1").style.backgroundColor="MistyRose";
document.getElementById("sub").style.backgroundColor="white";
window.location = "./index1.ejs";
}
</script>
请问你有什么想法吗?谢谢
【问题讨论】:
-
你不能直接从客户端访问ejs文件。你需要创建一个路由来渲染
index1.ejs然后把它添加到你的客户端window.location = "/route-url";
标签: javascript node.js express ejs