我对流星很陌生。我正在做简单的应用程序。
这是我遇到的问题:
Template.newFeedForm.events({
'submit #new-feed-form'(event) {
event.preventDefault();
const target = event.target;
const text = target.text;
Meteor.call('feeds.insert', text);
target.text.value = '';
}
});
所以我有 newFeedForm 模板,在我的 feeds.js 中我有
Meteor.methods({
'feeds.insert'(text){
check(text, String);
//check(hashtag, String);
// Make sure the user is logged in before inserting a task
if (! this.userId) {
throw new Meteor.Error('not-authorized');
}
console.log(this.userId);
// Feeds.insert({
// text: text,
// owner: this.userId,
// username: Meteor.users.findOne(this.userId).username,
// createdAt: new Date()
// });
}
});
我在这里注释掉了 Feeds.insert ,认为它会导致问题。看来是有些不一样了。
每当执行 Meteor.call 时,我都会得到以下信息:
Uncaught RangeError: Maximum call stack size exceeded
at Function._.(anonymous function) [as isArguments] (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:1068:30)
at Object.EJSON.clone (http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:512:25)
at http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:531:22
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:157:22)
at Object.EJSON.clone (http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:530:5)
at http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:531:22
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:157:22)
at Object.EJSON.clone (http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:530:5)
at http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:531:22
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:157:22)
不知道发生了什么。
这是我的存储库,它重现了此错误:https://github.com/yerassyl/nurate-meteor https://github.com/yerassyl/nurate-meteor
通常,当发生此类错误时(尤其是在处理 Meteor Method 时),这意味着您可能没有传递“正确”的数据(或您认为的数据)。
查看您的表单处理代码,我注意到您从未获得 textarea 文本数据。
const text = target.text;
target.text 返回实际的 textarea DOM 对象,但您真正想要的是该对象包含的值。下面的代码将解决您的问题。
const text = target.text.value;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)