Я создал сайт на основе Keystone JS, который использует рули. Я создал несколько моделей и шаблонов для них. Но когда я пытаюсь перейти на одну из страниц своего веб-сайта, я получаю следующую ошибку:
Handlebars: Access has been denied to resolve the property "title" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "coverImage" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "duration" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "distance" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "price" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "content" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "images" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Вот код страницы, которую я пытаюсь открыть:
Это мой файл маршрута:
let keystone = require('keystone');
exports = module.exports = function (req, res) {
let view = new keystone.View(req, res);
let locals = res.locals;
// Set locals
locals.section = 'tours';
locals.filters = {
trip: req.params.trip,
};
locals.data = {
trip: [],
};
view.on('init', function (next) {
keystone.list('Trip').model.findOne({
slug: locals.filters.trip,
}).exec(function (err, results) {
locals.data.trip = results;
console.log(locals.data.trip);
next(err);
});
});
view.render('trip');
};
И, наконец, вот модель:
let keystone = require('keystone');
let Types = keystone.Field.Types;
let Trip = new keystone.List('Trip', {
map: { name: 'title' },
singular: 'Trip',
plural: 'Trips',
autokey: { path: 'slug', from: 'title', unique: true },
});
Trip.add({
title: { type: String, required: true },
content: {
extended: { type: Types.Html, wysiwyg: true, height: 400 },
additional: { type: Types.Html, wysiwyg: true, height: 300 },
},
category: { type: Types.Relationship, ref: 'TripCategory' },
duration: { type: Types.Html, wysiwyg: false },
distance: { type: Types.Html, wysiwyg: false },
price: { type: Number },
images: { type: Types.CloudinaryImages },
coverImage: { type: Types.CloudinaryImage },
});
Trip.register();
Вот как это должно работать:
Вот как это работает:
Кстати, я проверил ссылку, которая была показана в ошибке, но я не знаю, где я должен использовать allowProtoPropertiesByDefault
( Я думаю, что я должен использовать именно этот код).
Вот ссылка: https://handlebarsjs.com/api-reference/runtime-options.html#options -to-control-prototype-access