vue-draggable-resizable icon indicating copy to clipboard operation
vue-draggable-resizable copied to clipboard

vue3引入后报错

Open lishihong opened this issue 4 years ago • 5 comments

image

lishihong avatar Nov 27 '20 09:11 lishihong

Are you planning to migrate this package to Vue 3?

s17472 avatar Feb 18 '21 11:02 s17472

Looking forward for Vue 3 compatibility

smg99 avatar Apr 21 '21 15:04 smg99

这咋整

syd192 avatar Jun 10 '21 02:06 syd192

any plans for v3?

simultsop avatar Jun 16 '21 11:06 simultsop

I think this actually works on Vue 3. It depends on How you use it.

To use it in vue 3, in your main.js/main.ts

// main.js
// Add the style
// Dont add the component here
import { createApp } from 'vue'
import App from './App.vue'
import 'vue-draggable-resizable/dist/VueDraggableResizable.css'

createApp(App).mount('#app')

To use the component just call the component from the src instead of taking it from the package.json

<template>
  <div
    style="
      height: 500px;
      width: 500px;
      border: 1px solid red;
      position: relative;
    "
  >
    <vue-draggable-resizable
      :w="100"
      :h="100"
      @dragging="onDrag"
      @resizing="onResize"
      :parent="true"
      :handles="['mr']"
      :draggable="false"
      class-name-handle="right-side-draggablbility"
    >
      <p>
        Hello! I'm a flexible component. You can drag me around and you can
        resize me.<br />
        X: {{ X }} / Y: {{ Y }} - Width: {{ Width }} / Height: {{ Height }}
      </p>
    </vue-draggable-resizable>
  </div>
</template>

<script>
// make sure your getting it in the components folder
import VueDraggableResizable from "vue-draggable-resizable/src/components/vue-draggable-resizable.vue";
import { ref } from "vue";
export default {
  name: "App",
  components: {
    VueDraggableResizable,
  },
  setup() {
    const Width = ref(0);
    const Height = ref(0);
    const X = ref(0);
    const Y = ref(0);

    return {
      Width,
      Height,
      X,
      Y,
      onResize: (x, y, width, height) => {
        X.value = x;
        Y.value = y;
        Width.value = width;
        Height.value = height;
      },
      onDrag: (x, y) => {
        X.value = x;
        Y.value = y;
      },
    };
  },
};
</script>

JenuelDev avatar Sep 08 '21 13:09 JenuelDev