Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 模板帮助程序中出现异常:TypeError:无法读取属性';单一类型';未定义的_Javascript_Meteor_Meteor Blaze_Meteor Autoform - Fatal编程技术网

Javascript 模板帮助程序中出现异常:TypeError:无法读取属性';单一类型';未定义的

Javascript 模板帮助程序中出现异常:TypeError:无法读取属性';单一类型';未定义的,javascript,meteor,meteor-blaze,meteor-autoform,Javascript,Meteor,Meteor Blaze,Meteor Autoform,我正在使用Meteor 1.6,并尝试使用aldeed的quickForm更新收藏。下面是我的代码 收藏: import { Mongo } from 'meteor/mongo'; import SimpleSchema from 'simpl-schema'; SimpleSchema.extendOptions(['autoform']); export const Settings = new Mongo.Collection('Settings'); SettingsSchema

我正在使用Meteor 1.6,并尝试使用aldeed的quickForm更新收藏。下面是我的代码

收藏

import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
SimpleSchema.extendOptions(['autoform']);

export const Settings = new Mongo.Collection('Settings');

SettingsSchema = new SimpleSchema({
    "userId": {
        type: String,
        label: "User ID",
    },
    "speed": {
        type: Number,
        label: "Speed",
    },
    "fuelLevel": {
        type: Number,
        label: "Fuel Level",
    },
    "fuelCapacity": {
        type: Number,
        label: "Fuel Capacity",
    },
    "temperature": {
        type: Number,
        label: "Temperature",
    },
}, { tracker: Tracker });

Settings.attachSchema(SettingsSchema);
Exception in template helper: TypeError: Cannot read property 'singleType' of undefined
    at SimpleSchema.getQuickTypeForKey (http://localhost:3000/packages/modules.js?hash=205c3cd7764df56011db912e818af184cf564869:30655:40)
    at Object.getInputType (http://localhost:3000/packages/aldeed_autoform.js?hash=51e89e15ba8f6061bd5bdff815c619d09399c305:2469:29)
    at Object.afFieldInputContext (http://localhost:3000/packages/aldeed_autoform.js?hash=51e89e15ba8f6061bd5bdff815c619d09399c305:6383:30)
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3051:16
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:1715:16
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3103:66
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3744:12)
    at http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3102:27
    at Object.Spacebars.call (http://localhost:3000/packages/spacebars.js?hash=547cf8e466d1d52603d19bd5f48fb5df184fd237:172:18)
    at http://localhost:3000/packages/aldeed_autoform.js?hash=51e89e15ba8f6061bd5bdff815c619d09399c305:6317:23
UI.js

import './ManageAlerts.html';
import '../../../components/common/staggering/Staggering';
import { Settings } from '/imports/api/users/settings';

window.Settings = Settings;

Template.ManageAlerts.onCreated(function () {
    console.log('Landed on page');
    this.subscribe('Settings.Individual');
});

Template.ManageAlerts.helpers({
    settings() {
        return Settings.find({ userId: Meteor.userId() });
    },
    Settings() {
        return Settings;
    }
});
UI.html

<template name="ManageAlerts">
    <div class="content">
        <div class="row">
            {{#each settings}} {{> quickForm collection="Settings" id=_id type="update" doc=this}} {{/each}}
        </div> 
    </div>
</template>

非常感谢您的帮助。

如果您的收藏未定义,则会发生此错误

一种可能的修复方法是将集合设置为全局,如下所示:

global.Settings = Settings; // try this instead of window
否则,您只需更改模板将集合返回表单的方式即可:

{{> quickForm collection=Settings id=_id type="update" doc=this}}
现在,它使用帮助器显式接收集合,而不是查看全局范围,因为您已经定义了此帮助器:

Settings() {
    return Settings;
}

如果这仍然不起作用,请检查集合是否通过给定的路径正确导入(例如,尝试不要以
/imports
开头,而是以当前目录开头)。

此问题是否仍然存在问题?