当然更简单的可以自己写个指令进行轮询Vue.directive('resize', {

bind(el, binding) {      let width = '', height = '';      function get() {        const style = document.defaultView.getComputedStyle(el);        if (width !== style.width || height !== style.height) {

binding.value({width, height});

}

width = style.width;

height = style.height;

}

el.__vueReize__ = setInterval(get, 200);

},

unbind(el) {

clearInterval(el.__vueReize__);

},

});

使用方式

这样轮询到div的width,height发生变化就会触发redraw事件了,directive是随手写的,测了下有效,没实用过,只提供个思路

Logo

前往低代码交流专区

更多推荐