Akryum / floating-vue

💬 Easy tooltips, popovers, dropdown, menus... for Vue
https://floating-vue.starpad.dev/
MIT License
3.28k stars 335 forks source link

Beta 22 Nuxt module: nuxt undefined #968

Closed joneath closed 1 year ago

joneath commented 1 year ago

The nuxt module blows up on nuxt boot. From the src it looks like this is undefined on line 2 const nuxt = this.nuxt. Any reason not to use either defineNuxtModule (probably don't want to add @nuxt/kit as a dependency) or use the passed nuxt instance as described in the docs?

Cannot read properties of undefined (reading 'nuxt')

orlanrepo commented 1 year ago

Didn't go into the details but I had the same problem when adding the float-vue/nuxt to modules in nuxt.config.ts.

I created my own plugin (a temp solution) :

/plugins/floating-vue.ts contents:

import { defineNuxtPlugin } from "#app";
import FloatingVue from "floating-vue";
import "floating-vue/dist/style.css";

export default defineNuxtPlugin((nuxtApp) => {
  // @TODO cutomization
  nuxtApp.vueApp.use(FloatingVue);
});

and floating-vue works in nuxt 3.5.3.

joneath commented 1 year ago

Didn't go into the details but I had the same problem when adding the float-vue/nuxt to modules in nuxt.config.ts.

I created my own plugin (a temp solution) :

/plugins/floating-vue.ts contents:

import { defineNuxtPlugin } from "#app";
import FloatingVue from "floating-vue";
import "floating-vue/dist/style.css";

export default defineNuxtPlugin((nuxtApp) => {
  // @TODO cutomization
  nuxtApp.vueApp.use(FloatingVue);
});

and floating-vue works in nuxt 3.5.3.

This was the documented solution to using the package in Nuxt prior to beta 21 when supposedly a in package nuxt module was added. Beta 22 added the module but in a broken state 😔