流星:未捕获的范围错误:超出最大调用堆栈大小 [英] Meteor: Uncaught RangeError: Maximum call stack size exceeded

查看:46
本文介绍了流星:未捕获的范围错误:超出最大调用堆栈大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Meteor 很陌生.我正在做简单的应用程序.这是我遇到的问题:

I am very new to Meteor. I am doing simple app. Here is the problem I have:

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 中有

So I have newFeedForm template and in my feeds.js I have

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 执行时,我都会得到这个:

I commented out the Feeds.insert here thinking that it causes the problem. Seems it is something different. Whenever Meteor.call is executed I got this:

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

Have no Idea what is happening. Here is my repo that reproduces this error: https://github.com/yerassyl/nurate-meteor

推荐答案

通常,当发生这样的错误时(尤其是在处理 Meteor 方法时),这意味着您可能没有传递正确"的数据(或你以为你是).

Typically, when errors like this occur (especially when dealing with a Meteor Method) it means you are probably not passing the "correct" data (or the data that you thought you were).

查看您的表单处理代码,我注意到您从未获得 textarea 文本数据.

Looking at your form handling code, I noticed that you are never obtaining the textarea text data.

const text = target.text;

target.text 返回实际的 textarea DOM 对象,但您真正想要的是该对象包含的值.以下代码将解决您的问题.

target.text returns the actual textarea DOM object but what you are really after is the value the object contains. The below code will solve your issue.

const text = target.text.value;

这篇关于流星:未捕获的范围错误:超出最大调用堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆