SyntaxError:编译ejs时index.ejs中出现意外标识符

问题描述 投票:0回答:1
<body>
        <header>
            <% include templates/header.ejs %>
        </header>
            <% include templates/announcement.ejs %>
        <form>
            <br><input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search a fort...">
        </form><br>
        <section id="placeList">
            <div class="placeListBackground" id="placeListGet">
             <ul id="placeCells">
                <% placeData.forEach(function(placeData) { %>
                    <div class="placeContainer <%= placeData.category %>" class><a href = "https://www.roblox.com/games/<%= placeData.placeid %>/-"><img src= "<%= placeData.placeicon %>" alt="<%= placeData.placename %>" align="left" width="178" height="100"><span><%= placeData.placename %></span><p><%= placeData.clan %></p><p>Playing: <%= placeData.playing %></p><p class="sCategory"><%= placeData.category %></p></a></div>
                <% }); %>
             </ul>
            </div>
        </section>
        <br><footer>Contact us: https://discord.gg/fMb5y7T</footer>
    </body>
    <% include templates/search.ejs %>

我已经检查并测试了很多不同的ejs标签,以防万一,但是我不明白为什么这不起作用。以前可以使用,但是除非ejs的错误,否则我必须忽略一些问题?

javascript node.js ejs
1个回答
0
投票

现在,ejs某些功能的语法已更改。就您而言,

您已经写道:<% include templates/file.ejs %>

并且应该是:<%- include ("templates/file.ejs") %>

至少我遇到了同样的问题并以这种方式解决了,我希望是有用的。查找有关ejs更改的更多信息:https://github.com/RyanZim/EJS-Lint

© www.soinside.com 2019 - 2024. All rights reserved.