Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with @vue/compat #145

Open
davidwessman opened this issue Aug 11, 2023 · 2 comments
Open

Errors with @vue/compat #145

davidwessman opened this issue Aug 11, 2023 · 2 comments

Comments

@davidwessman
Copy link

Hello!

I am trying to migrate from Vue 2 to Vue 3 and currently running:

  • vue: 3.3.4
  • @vue/compat: 3.3.4
  • vue-easy-dnd: 2.1.3

MODE: 2

<drop-list
  :items="localMeetings"
  :no-animations="true"
  class="list-group list-group-flush"
  @reorder="reorderItems"
>
  <template #item="item">
    <drag :key="item.number" class="item" handle=".handle">
      {{ item }}
    </drag>
  </template>
 </drop-list>

If I set

compatConfig: {
  MODE: 2
}

then I get the error

Uncaught TypeError: this.$slots.item is not a function

which makes sense since you are not supporting Vue 2 anymore.

MODE: 3

If I switch to:

<drop-list
  :items="localMeetings"
  :no-animations="true"
  class="list-group list-group-flush"
  @reorder="reorderItems"
>
  <template #item="{item}">
    <drag :key="item.number" class="item" handle=".handle">
      {{ item }}
    </drag>
  </template>
 </drop-list>
compatConfig: {
  MODE: 3
}

then I get the error:

Cannot destructure property 'item' of 'undefined' as it is undefined.

I am not sure what is required by a library to work with @vue/compat, would be greatful for any help.

@GhostNr1
Copy link

What I did when I was doing our migration was to do

setup() {
    DragList.compatConfig = {
      MODE: 3
    };
    Drag.compatConfig = {
      MODE: 3
    };
  },

And run everything else under MODE: 2. Every component that is vue3 ready you can do this with until the current component you are working with are fully Vue3 compatible and change that component to.
I never get it working with {} in item so I do it like this now

<drop-list
            :items="localMeetings"
            class="someClasses"
            @reorder="meetingMoved($event)"
          >
            <template #item="subTask">
              <drag
                :key="subTask.item.uuid"
                class="subtaskClass"
              >
                <div
                  :key="subTask.item.uuid"

Hope this can help someone that is in the same situation when they need to change one 3:rd party component that need to be run in MODE: 3 and not 2 but the first component isn't compatible yet.

@davidwessman
Copy link
Author

davidwessman commented Aug 31, 2023

Thank you @GhostNr1, will try it out!

Edit:

Worked like a charm!
@rlemaigre would it make sense to add something about this to the documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants