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

Failed to resolve directive: auto-animate #169

Open
WouS95 opened this issue Oct 4, 2023 · 4 comments
Open

Failed to resolve directive: auto-animate #169

WouS95 opened this issue Oct 4, 2023 · 4 comments

Comments

@WouS95
Copy link

WouS95 commented Oct 4, 2023

I just updated the plugin used in my Vue.js application. (running Vite)
I'm using auto-animate to animate a custom component (which is a list item). After the update I get a bunch of the following warning:

Failed to resolve directive: auto-animate

The animation also doesn't work anymore.

I import using this line:
import { vAutoAnimate } from '@formkit/auto-animate';

Then in my template the following code:

 <ul v-if="vossenteams" id="voslocaties" v-auto-animate>
        <Voslocatie v-for="voslocatie in foxLocations" :key="voslocatie.id" :voslocatie="voslocatie"
          :vossenteams="vossenteams" />
      </ul>

<Voslocatie .../> is my custom component containing a template with <li>

In my package.json i made sure to use version 0.8.0 (removed the package from the node_modules folder and reinstalled with npm install)
"@formkit/auto-animate": "^0.8.0",

I can't figure out what is going wrong. Could you please help me out? Thanks!

@justin-schroeder
Copy link
Member

Are you using composition api?

@WouS95
Copy link
Author

WouS95 commented Oct 5, 2023

Yes I am!

@justin-schroeder
Copy link
Member

Hmm. Then I would need to see a reproduction.

@WouS95
Copy link
Author

WouS95 commented Oct 6, 2023

I found out why it didn't work. I made a small new project and tried to reproduce it.

The difference was I am using the 'old' composition api with the setup function like this:
Following code doesn't work and produces the failed to resolve warning:

<script lang="ts">
import { ref } from 'vue';
import HelloWorld from './components/HelloWorld.vue'
import vAutoAnimate from '@formkit/auto-animate';

export default {
  components: {
    HelloWorld,
  },
  setup() {

    const objectlist = ref([{ id: 1 }, { id: 2 }, { id: 3 }])
    const addListItem = () => {
      objectlist.value.push({ id: objectlist.value.length + 1 })

    }
    return {
      objectlist,
      addListItem,
      vAutoAnimate,
    }
  }

}
</script>

I need to refactor to something like this to get it to work:

<script setup lang="ts">
import { ref } from 'vue';
import HelloWorld from './components/HelloWorld.vue'
import vAutoAnimate from '@formkit/auto-animate';
const objectlist = ref([{ id: 1 }, { id: 2 }, { id: 3 }])
const addListItem = () => {
  objectlist.value.push({ id: objectlist.value.length + 1 })
}
</script>

So put the setup keyword inside the script tag. I will try to refactor this on my main project as well.

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