@@ -57,57 +57,34 @@ Register the component globally
5757
5858``` js
5959// main.js
60- import createApp from ' vue'
60+ import { createApp } from ' vue'
6161import VueDraggableResizable from ' vue-draggable-resizable'
62- // optionally import default styles
63- import ' vue-draggable-resizable/dist/VueDraggableResizable.css'
64- import App from ' /src/App.vue'
62+ import App from ' ./App.vue'
6563
66- const app = createApp (App)
67- app .component (' vue-draggable-resizable' , VueDraggableResizable)
64+ createApp (App)
65+ .component (" vue-draggable-resizable" , VueDraggableResizable)
66+ .mount (' #app' )
6867```
6968
7069You may now use the component in your markup
7170
7271``` vue
72+ // App.vue
7373<template>
7474 <div style="height: 500px; width: 500px; border: 1px solid red; position: relative;">
75- <vue-draggable-resizable :w="100" :h="100" @dragging="onDrag" @resizing="onResize" :parent="true">
76- <p>Hello! I'm a flexible component. You can drag me around and you can resize me.<br>
77- X: {{ x }} / Y: {{ y }} - Width: {{ width }} / Height: {{ height }}</p>
75+ <vue-draggable-resizable :w="100" :h="100" :parent="true">
76+ <p>Hello! I'm a flexible component. You can drag me around and you can resize me.</p>
7877 </vue-draggable-resizable>
7978 </div>
8079</template>
80+ ```
8181
82- <script>
83- import VueDraggableResizable from 'vue-draggable-resizable'
82+ The component itself does not include any CSS. You'll need to include it separately in your ` App.vue ` :
8483
85- export default {
86- components: {
87- 'vue-draggable-resizable': VueDraggableResizable
88- },
89- data: function () {
90- return {
91- width: 0,
92- height: 0,
93- x: 0,
94- y: 0
95- }
96- },
97- methods: {
98- onResize: function (x, y, width, height) {
99- this.x = x
100- this.y = y
101- this.width = width
102- this.height = height
103- },
104- onDrag: function (x, y) {
105- this.x = x
106- this.y = y
107- }
108- }
109- }
110- </script>
84+ ``` vue
85+ <style>
86+ @import "vue-draggable-resizable/style.css";
87+ </style>
11188```
11289
11390### Props
0 commit comments