lax.js client-side plugin - "window.lax is undefined" #9707
Unanswered
thely
asked this question in
Questions (Nuxt 2)
Replies: 1 comment
-
@thely Likely the issue is the import into your client plugin. Although the plugin is client-only, it is still imported into your server build, just not executed. Try using a dynamic import within the function body instead. For example: import Vue from "vue";
export async default () => {
const lax = await import("lax.js/lib/lax.js");
Vue.prototype.$lax = lax;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I love the look of lax.js, and it offers things that some other parallax libraries don't. Problem is, I can't get it working with Nuxt! I keep getting
window.lax is undefined
no matter how I try to client-side-plugin this library.Versions
nuxt: 2.15.3
Reproduction
Make a plugin to handle the library, add it to the Vue prototype, no dice.
@/plugins/lax.js
registering the plugin in
nuxt.config.js:
in a component:
Steps to reproduce
As above.
What is Expected?
By doing as many things as I possibly can to ensure that the window exists when
lax.init()
is called, I would expect thewindow
to exist by now. But apparently, it doesn't!I've also tried this where I load it on the component itself instead of using a plugin (
require()
it on mounted()), still saying
window.lax is undefined`. I have no idea if this is a fault of the lax.js library, but I figured I'd eliminate the Nuxt part of it first (since that's the part I have control over!).What is actually happening?
window.lax is undefined
.Beta Was this translation helpful? Give feedback.
All reactions