[Vuejs]-Getting null value of the height of the div in a vue component when hosted on the net

0👍

There is no guarantee that the instance is mounted when the callback to scroll the browser window is executed.

You should scroll the browser window on guarantee that the instance is mounted and all its children. This provides certainty that by the time jquery selection for #myDiv is made, the template has rendered to the browser. e.g.

...

mounted: function () {
    const scrollDiv = function () {
        const myDiv = $(this.$el).find("#myDiv");
        myDiv.scrollTop(myDiv[0].scrollHeight);
    }
    this.$nextTick(scrollDiv);
}

Leave a comment