moonlik
329
1
Vue

DOMException: Failed to execute 'insertBefore' on 'Node'

Posted 2 years ago by moonlik

I have the error in the console

DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

When trying to reproduce this code of vue component:

<template>
  <div class="modal is-active has-text-centered">
    <div class="modal-background" @click="$emit('close')"></div>
    <div class="modal-card">
      <section class="modal-card-body">
        <slot></slot>
      </section>
    </div>
  </div>
</template>

<script>
export default {
  mounted() {
    document.getElementById('app').appendChild(this.$el);
  },
};
</script>

The error exists only when I click on the modal-background. Any ideas how can I solve it?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.