这是错误的 TypeError:C:\ users \ gaffer \ desktop \ 6th Semester \ GafferCart \ views \ admin \ add_product.ejs:22
执行(默认):SELECT count(*)AS count
FROM Products
AS Product
;
执行(默认):SELECT id
,title
,slug
,desc
,category
,price
,images
FROM {{ 1}} AS Products
LIMIT 1;
执行(默认):SELECT Product
,id
,title
FROM slug
AS Categories
LIMIT 1;
Category
>
无法读取属性' forEach'为null
20| <label for="">Category</label>
21| <select name="category" class="form-control">
>> 22| <% categories.forEach(function(cat){ %>
23| <option value="<%= cat.slug %>"><%= cat.title %
</option>
24| <% }); %>
25| </select
答案 0 :(得分:0)
您的categories对象为null,请控制该对象。