vue.draggable.next icon indicating copy to clipboard operation
vue.draggable.next copied to clipboard

Dose not work with composition api?

Open huangche007 opened this issue 4 years ago • 5 comments

First check https://github.com/SortableJS/Vue.Draggable/blob/master/CONTRIBUTING.md

Hi, when i use this plugin in vue3,it dose not work(view dose not show correctly)。

"vuedraggable": "^4.0.3"

example is there:

<draggable 
  v-model="testPeoples " 
  @start="drag=true" 
  @end="drag=false" 
  item-key="id">
  <template #item="{element}">
    <div>{{element.name}}</div>
   </template>
</draggable>

<script lang="ts">
import { defineComponent, ref, Ref, watch } from 'vue'
import draggable from 'vuedraggable'

export default defineComponent({
  components: {
    draggable,
  },
  setup(props, ctx) {
     const drag = ref<boolean>(false)
     const testPeoples = ref([
        {
          id: '123',
          name: '黄澈',
          checked: false,
        },
        {
          id: '1231',
          name: '黄澈1',
          checked: false,
        },
        {
          id: '1232',
          name: '黄澈2',
          checked: false,
        },
        {
          id: '1233',
          name: '黄澈3',
          checked: false,
        },
        {
          id: '1234',
          name: '黄澈4',
          checked: false,
        },
        {
          id: '1235',
          name: '黄澈5',
          checked: false,
        },
      ])
     return {
        testPeoples,
        drag
    }
}
})
</script>

huangche007 avatar Jun 15 '21 08:06 huangche007

when i use toRaw api,it also dose not work:

 import { defineComponent, ref, Ref, watch, toRaw } from 'vue'
 let mList: Array<any[]> = []
 mList = toRaw(checkedList.value)

 <draggable 
    v-model="mList" 
    @start="drag=true" 
    @end="drag=false" 
    item-key="id">
      <template #item="{element}">
        <div>{{element.name}}</div>
       </template>
 </draggable>

huangche007 avatar Jun 15 '21 08:06 huangche007

Hey!, any update on this issue? did you come up with the solution?

jesusgabri3l avatar Jun 30 '21 20:06 jesusgabri3l

澈哥真有缘

miskying avatar Jul 02 '21 09:07 miskying

I also don't see anything after installing with yarn. just doesn't appear.

Vue version: [email protected]

hb0nes avatar Jul 18 '21 11:07 hb0nes

Actually it does work in composition API. I reread the instructions and forgot to import draggable and expose it as a component. Stuff works beautifully now.

hb0nes avatar Jul 20 '21 14:07 hb0nes