.forEach()函数无法识别数组中的元素

时间:2018-09-29 21:13:23

标签: javascript node.js ejs

有一个mysql_user文件,其中包含一个.ejs函数,我正在使用该函数遍历数组。该数组只有一个元素,将来会添加元素。

代码如下:

.forEach

这是错误:

<div class="bg-white jumbotron no-shadow">
    <div class="container">
        <div class="row">
            <div class="col-md-6 col-sm-12">
                <%
                    if(apiResults.featured.male){
                        %>
                            <div class="row">
                                Array.from(apiResults.featured.male).forEach((profile) => {
                                    %>
                                        <div class="col-xs-4">
                                            <%=profile.name%>
                                        </div>
                                    %<
                                })
                            </div>
                        <%
                    }
                %>  
            </div>
        </div>
    </div>
</div>

有人可以告诉我为什么它无法识别profile is not defined at eval (eval at compile (C:\projects\Heartenly\node_modules\ejs\lib\ejs.js: 618:12), <anonymous>:19:37) at returnedFn (C:\projects\Heartenly\node_modules\ejs\lib\ejs.js:653:17) at include (C:\projects\Heartenly\node_modules\ejs\lib\ejs.js:651:39) at eval (eval at compile (C:\projects\Heartenly\node_modules\ejs\lib\ejs.js: 618:12), <anonymous>:113:8) at returnedFn (C:\projects\Heartenly\node_modules\ejs\lib\ejs.js:653:17) at include (C:\projects\Heartenly\node_modules\ejs\lib\ejs.js:651:39) at eval (eval at compile (C:\projects\Heartenly\node_modules\ejs\lib\ejs.js: 618:12), <anonymous>:48:17) at returnedFn (C:\projects\Heartenly\node_modules\ejs\lib\ejs.js:653:17) at tryHandleCache (C:\projects\Heartenly\node_modules\ejs\lib\ejs.js:251:36) at View.exports.renderFile [as engine] (C:\projects\Heartenly\node_modules\e js\lib\ejs.js:482:10) 吗?

0 个答案:

没有答案