![请添加图片描述](https://img-blog.csdnimg.cn/10a4819638774651a9db0743fcb8535d.gif)
directives: {
resize: {
bind (el, binding) {
let width = '', height = '';
function isReize () {
const style = document.defaultView.getComputedStyle(el);
if (width !== style.width || height !== style.height) {
binding.value();
}
width = style.width;
height = style.height;
}
el.__vueSetInterval__ = setInterval(isReize, 300);
},
unbind (el) {
clearInterval(el.__vueSetInterval__);
}
}
},
methods:{
resize () {
console.log('我变了')
},
}
template
<div class="shichang borderColor"
v-resize="resize"
style="clear:both;margin-top:16px;">
要监控的区域
</div>