How to add a third-party custom element? #18196
-
In Nuxt v2, I was able to add third party custom element globally using plugins in the nuxt config: plugins: [ and then use it in my templates. What's the correct way to do that in v3? For reference, the elements I am looking to import were built using LitElement, and they register themselves as custom elements using customElements.define... |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 12 replies
-
Related https://github.com/nuxt/framework/discussions/1214 |
Beta Was this translation helpful? Give feedback.
-
import { createVuetify } from 'vuetify' export default defineNuxtPlugin((nuxtApp) => { |
Beta Was this translation helpful? Give feedback.
-
You can do it like this: import { defineNuxtConfig } from 'nuxt3'
export default defineNuxtConfig({
build: {
transpile: ['vaadin']
},
vue: {
compilerOptions: {
isCustomElement: tag => ['vaadin-checkbox'].includes(tag)
}
}
})
import '@vaadin/vaadin-checkbox'
export default () => {} |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm new to Nuxt, directly starting with the version 3 (why not!). I'm trying to use this Vue3 component https://github.com/SortableJS/vue.draggable.next and found this discussion, how to add a third-party custom element. So I created a
And then in my page I use it (without adding nothing in the script setup):
But it's not working, and the console displays
What I am missing? Thank you |
Beta Was this translation helpful? Give feedback.
You can do it like this:
~/plugins/components.client.ts