@aleshaykovlev
html, css, js, node, webpack, sass, react

Не понимаю, что не так, ошибка в цикле each, как исправить?

Цикл:
<ul class="list-cards">
                            {{#each products}}
                                <li class="card" data-size="{{size}}">
                                    <a href="/products/{{id}}" title="{{title}}">
                                        <div class="card__block-img">
                                            <figure>
                                                <img src="{{img}}" alt="{{title}}">
                                            </figure>
                                        </div>
                                        <div class="card__description">
                                            <span class="card-name">{{title}}</span>
                                            <div class="card__block-price">
                                                <span class="card-old-price">{{oldPrice}}</span>
                                                <span class="card-now-price">{{nowPrice}}</span>
                                                <span class="card-sale">{{sale}}</span>
                                            </div>
                                        </div>
                                    </a>
                                </li>
                            {{/each}}
                        </ul>


Ошибка:
Handlebars: Access has been denied to resolve the property "size" because it is not an "own property" of its parent.
[0] You can add a runtime option to disable the check or this warning:
[0] See https://handlebarsjs.com/api-reference/runtime-opt... for details
[0] Handlebars: Access has been denied to resolve the property "id"
because it is not an "own property" of its parent.
[0] You can add a runtime option to disable the check or this warning:
[0] See https://handlebarsjs.com/api-reference/runtime-opt... for details
[0] Handlebars: Access has been denied to resolve the property "title" because it is not an "own property" of its parent.
[0] You can add a runtime option to disable the check or this warning:
[0] See https://handlebarsjs.com/api-reference/runtime-opt... for details
[0] Handlebars: Access has been denied to resolve the property "img" because it is not an "own property" of its parent.
[0] You can add a runtime option to disable the check or this warning:
[0] See https://handlebarsjs.com/api-reference/runtime-opt... for details
[0] Handlebars: Access has been denied to resolve the property "oldPrice" because it is not an "own property" of its parent.
[0] You can add a runtime option to disable the check or this warning:
[0] See https://handlebarsjs.com/api-reference/runtime-opt... for details
[0] Handlebars: Access has been denied to resolve the property "nowPrice" because it is not an "own property" of its parent.
[0] You can add a runtime option to disable the check or this warning:
[0] See https://handlebarsjs.com/api-reference/runtime-opt... for details
[0] Handlebars: Access has been denied to resolve the property "sale" because it is not an "own property" of its parent.
[0] You can add a runtime option to disable the check or this warning:
[0] See https://handlebarsjs.com/api-reference/runtime-opt... for details
  • Вопрос задан
  • 252 просмотра
Пригласить эксперта
Ответы на вопрос 1
@TheBladeHit
Developer
В главном файле к настройкам добавь код:

const hbs = exhbs.create({
defaultLayout: 'main',
extname: 'hbs',
runtimeOptions: {
allowProtoPropertiesByDefault: true,
allowProtoMethodsByDefault: true,
}
});

app.engine('hbs', hbs.engine);
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы