小编Mir*_*ana的帖子

SyntaxError: missing ) 在编译 ejs 时的参数列表之后

我在编译 ejs 时在参数列表之后收到错误:缺少 )。我尝试了很多次,但我找不到问题所在。

这是导致错误的 ejs。这段代码有什么问题?

<%- include('../_layouts/adminheader') %>

<h2 class='page-title'>Products</h2>
<br>
<a href="/admin/products/add-product" class="btn btn-primary">Add a new product</a>
<br><br>

<% if (count > 0) { %>

<table class="table table-striped">
    <thead>
        <tr class="home">
            <th>Product</th>
            <th>Price</th>
            <th>Category</th>
            <th>Product Image</th>
            <th>Edit</th>
            <th>Delete</th>
        </tr>
    </thead>
    <tbody>
        <% products.forEach(function(product) { %>
        <tr>
            <td><%= product.title %></td>
            <td>$<%= parseFloat(product.price).toFixed(2) %></td>
            <td><%= product.category %></td>
            <td>
                <% if (product.image == "") { %>
                <img src="/images/noimage.png">
                <% } else { %>
                <img src="product_images/<%= product._id %>/<%= product.image %>">
                <% }%> …
Run Code Online (Sandbox Code Playgroud)

javascript syntax-error ejs

5
推荐指数
1
解决办法
8208
查看次数

标签 统计

ejs ×1

javascript ×1

syntax-error ×1