R
R
Renhor2019-11-06 18:27:58
Vue.js
Renhor, 2019-11-06 18:27:58

Cut the Vue component and paste it into the body of the site. What is fraught with?

Are there any consequences or possible errors for such code?

mounted() {
    const el = this.$el.parentNode.removeChild(this.$el);
      
    document.body.appendChild(el);
},
destroyed() {
    document.body.removeChild(this.$el);
},

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2019-11-06
@Renhor

I did this for the moving panels, it will not cause any problems.
I got the following code for the panel itself or, in your case, the window

mounted() {
            document.addEventListener('click', () => this.closePanel());
            document.body.appendChild(this.$el);
            document.body.style.overflow = "hidden";
            setTimeout(() => this.isOpened = true, 100)
        },
        beforeDestroy() {
            this.isOpened = false;
            document.body.style.overflow = "auto";
        },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question