lax.js icon indicating copy to clipboard operation
lax.js copied to clipboard

HTML class presets are broken in NuxtJS (+probably Vue)

Open thely opened this issue 3 years ago • 3 comments

In NuxtJS, using the HTML class presets turns up a window.lax is undefined error no matter how hard I try to make sure my plugin encapsulation of this library is actually client-side, which I definitely spent the better part of a day hitting my head against the wall over. But the lax.addElements() version of this library works fine in Nuxt so far. My guess is that the presets will probably break similarly in Vue, but I haven't tested that.

Here's my Codesandbox link. The index page uses lax.addElements() and works, the about page uses HTML classes and breaks.

thely avatar Aug 20 '21 17:08 thely

Also having this issue. Getting the same error as in the codesandbox above.

Cannot read property 'presets' of undefined

antiantivirus avatar Oct 12 '21 10:10 antiantivirus

Hack/fix available here https://github.com/alexfoxy/lax.js/issues/139

adding window.lax = { presets: this.$lax.presets } to mounted fixed the issue for me.

antiantivirus avatar Oct 12 '21 10:10 antiantivirus

I have the very same problem with React. It just throws:

Uncaught TypeError: Cannot read properties of undefined (reading 'presets')

derwaldgeist avatar May 19 '22 14:05 derwaldgeist