首页 > 解决方案 > 在 express 中访问部分视图时出现问题

问题描述

这是我的视图文件:views/profile.ejs

<body>
    <% include partial/nav.ejs %>
    <!-- <%- include('partial/nav.ejs'); %> -->
    <h1>    Welcome to <%= person %> profile</h1>
    <p>
       <strong>The age: </strong><%= proObj.age%> 
    </p>
    <p>
        <strong>Relationship Status: </strong><%= proObj.relation_status%> 
    </p>
    <div>
        <p>
            <strong>Hobbies: </strong>
                <% hobbies.forEach(function(item){ %>
                    <li>  <%= item %> </li>
                    <% }); %>

        </p>
    </div>
</body>

和这个部分视图文件:views/partial/nav.ejs

<nav>
<ul>
<li><a href="">Home</a></li>
<li><a href="">Contact</a></li>

当我重新加载网站时,我将这个错误弹出到服务器中

SyntaxError: Unexpected identifier in C:\Users\Fo0ola\Desktop\SERVER-SIDE\views\profile.ejs while compiling ejs

标签: node.jsexpressejs

解决方案


推荐阅读