gregos919
gregos919

Reputation: 47

Vue - watch for changes on this.$el.clientWidth

Is it possible to watch for changes on components element clientWidth (this.$el.clientWidth)? Something like:

 this.$watch(
        () => {
            return this.$el.clientWidth;
        },
        (newWidth, oldWidth) => {
            console.log(newWidth);
        }
    )

Upvotes: 4

Views: 3301

Answers (1)

しぶやたくみ
しぶやたくみ

Reputation: 11

I am investigating the same problem. I think the solution dependent on the HTML lifecycle is effective in some cases. I am pleased if my solution at the present stage will serve you.

mousemove (e) {
    this.clientWidth = this.$el.clientWidth
}

Upvotes: 1

Related Questions