撇号片教程:自我不是一个功能

时间:2017-02-16 10:05:02

标签: apostrophe-cms

片段教程(http://apostrophecms.org/docs/tutorials/getting-started/reusable-content-with-pieces.html)中的以下代码片段给出了类型错误: self [name]不是函数 - 在lib / modules /撇号的第1031行 - 文档/ LIB /光标。

单击保存按钮以添加新人或保存该片时,会发生错误。

我理解这可能会发生,因为对象实际上并不是我想的那样,或者因为它返回一个空值。两者似乎都不太可能。

当我按照教程逐步完成时,我只浏览了光标部分。

people.index.js文件如下:

module.exports = {
    extend: 'apostrophe-pieces',
    name: 'person',
    label: 'Person',
    pluralLabel: 'People',
    addFields: [
        {
            name: 'title',
            label: 'Full Name',
            type: 'string',
            required: true,
            contextual: true
        },
        {
            name: 'firstName',
            label: 'First Name',
            type: 'string',
            required: true
        },
        {
            name: 'lastName',
            label: 'Last Name',
            type: 'string',
            required:true
        },
        {
            name: 'body',
            label: 'Biography',
            type: 'area',
            options: {
                widgets: {
                    'apostrophe-rich-text': {
                        controls: [ 'Bold', 'Italic', 'Link', 'Unlink' ]
                    },
                    'apostrophe-images': {}
                }
            }
        },
        {
            name: 'phone',
            label: 'Phone',
            type: 'string'
        },
        {
            name: 'thumbnail',
            label: 'Thumbnail',
            type: 'singleton',
            widgetType: 'apostrophe-images',
            options: {
                limit: 1,
                minSize: [ 200, 200 ],
                aspectRatio: [ 1, 1 ]
            }
        }
    ],
    arrangeFields: [
        {
            name: 'contact',
            label: 'Contact',
            fields: [ 'firstName', 'lastName', 'phone' ]
        },
        {
            name: 'admin',
            name: 'Admin',
            fields: [ 'slug', 'published', 'tags' ]
        },
        {
            name: 'content',
            name: 'Biographical',
            fields: [ 'thumbnail', 'body' ]
        }
    ],
    construct: function(self, options) {
        var superPushAssets = self.pushAssets;
        self.pushAssets = function() {
          superPushAssets();
          self.pushAsset('stylesheet', 'always', { when: 'always' });
        };
    },
    construct: function(self, options) {
        self.beforeSave = function(req, piece, options, callback) {
          piece.title = piece.firstName + ' ' + piece.lastName;
          return callback();
        };
    }
};

0 个答案:

没有答案