# Guide
# Getting Started
# Setup
$ npm install vue-element-resize-detector
1
# 🚀 How to use in Vue
In main.js
import resize from "vue-element-resize-detector";
Vue.use(resize)
1
2
3
2
3
<template>
<div id="app">
<h1>Vue Element Resize Detector</h1>
<div v-resize @resize="onResize">This divs with is: {{ width }}</div>
</div>
</template>
<script>
export default {
name: "app",
data() {
return {
width: 0
};
},
methods: {
onResize(e) {
console.log("resize event", e.detail.width, e.detail.height);
this.width = e.detail.width;
}
}
};
</script>
<style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Support
Please give a ⭐️ if this project helped you!
# Contributing
If you have any questions or requests or want to contribute to vue-element-resize-detector
or other packages, please write the issue or give me a Pull Request freely.
# Bug Report
If you find a bug, please report to us opening a new Issue on GitHub.