【问题标题】:Meteor: Exception in queued task: Error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node流星:排队任务中的​​异常:错误:无法在“节点”上执行“removeChild”:要删除的节点不是该节点的子节点
【发布时间】:2015-02-27 22:43:50
【问题描述】:

我有一个非常奇怪的问题,完全不知道如何解决它。

我正在尝试构建非常简单的 fullpage.jsmeteor.js 实现。下面的代码有效,但几分钟后,它就中断了。当我打开一个新的隐身窗口时,它会再次运行几分钟,但是当我刷新页面时,我收到以下错误 3 次(集合中的每个文档一个)。

Exception in queued task: Error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
at Error (native)
at DOMRange.detach (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:512:24)
at DOMRange.setMembers (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:471:12)
at DOMRange.addMember (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:540:10)
at http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2541:32
at Object.Tracker.nonreactive (http://localhost:3000/packages/tracker.js?517c8fe8ed6408951a30941e64a5383a7174bcfa:513:12)
at Object.Blaze.Each.eachView.onViewCreated.eachView.stopHandle.ObserveSequence.observe.addedAt (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2528:17)
at Object.cursor.observe.addedAt (http://localhost:3000/packages/observe-sequence.js?2fd807ea171ead273b9e6458607cb226012d9240:339:19)
at LocalCollection._observeFromObserveChanges.observeChangesCallbacks.addedBefore (http://localhost:3000/packages/minimongo.js?e8806aa7782b729b2517ebc0cd10b321667f1427:3840:28)
at Object.LocalCollection._CachingChangeObserver.self.applyChange.addedBefore (http://localhost:3000/packages/minimongo.js?e8806aa7782b729b2517ebc0cd10b321667f1427:3777:56)

流星垫:http://meteorpad.com/pad/RT4HwXmXW6wbghNhK/Fullpage

ma​​in.html

<head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>
    {{>fullPage}}
</body>

<template name="fullPage">
        <div id="fullpage" class="section">
                {{#each products}}
                    <div class="slide"><h2>{{name}}</h2></div>
                {{/each}}
            </div>
</template>

client/app.js

Template.fullPage.rendered = function () {
    $('#fullpage').fullpage();
};

Template.fullPage.helpers({
    products: function () {
        return Products.find();
    }
});

服务器/app.js

Meteor.startup(function () {
  if (Products.find().count() === 0) {

    var Product1 = Products.insert({
        name: "1"
    });

    var Product2 = Products.insert({
        name: "2"
    });

    var Product3 = Products.insert({
        name: "3"
    });
  }
});

common.js

Products = new Mongo.Collection('products');

【问题讨论】:

标签: javascript node.js meteor meteor-blaze fullpage.js


【解决方案1】:

在您的{{#each products}} 周围添加&lt;div&gt; 可能会解决您的问题。

我不熟悉 fullpage.js,但我收到了与 maazalik:malihu-jquery-custom-scrollbar 包完全相同的错误消息。该插件通过将元素复制并粘贴到新 div 中来操作,如果该元素的第一个子元素是 {{#each}}{{#if}},这可能会导致问题。添加&lt;div&gt; 解决了这个问题。

您可以在此github issue 中找到更多信息。

【讨论】:

    【解决方案2】:

    您可以尝试在每个函数中添加else 看看它是否解决了什么问题?

    <template name="fullPage">
        <div id="fullpage" class="section">
                {{#each products}}
                    <div class="slide"><h2>{{name}}</h2></div>
                {{else}}
                  {{! does this help? }}
                {{/each}}
            </div>
    </template>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-17
      • 1970-01-01
      • 2022-11-12
      • 2018-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多