Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

491
Views
Cómo usar un componente vue3 (vue.draggable.next) dentro del proyecto Nuxt 3 como complemento

En mi proyecto recién iniciado, quería usar vue.draggable.next . Así que creé un archivo ".js" dentro del directorio del complemento nuxt y agregué el código como se muestra a continuación.

 import VueDraggableNext from "vue-draggable-next"; export default defineNuxtPlugin((nuxtApp) => { nuxtApp.vueApp.use(VueDraggableNext); });

Luego lo usé en uno de mis componentes como se muestra a continuación,

 <template> <div class="h-full w-full border-2 border-dashed rounded-lg p-5 flex"> <div class="flex w-1/6 h-full"> <ComponentPalette /> </div> <VueDraggableNext v-model="form.children" group="people" @start="isDragOver = true" @end="isDragOver = false" item-key="id" class="flex flex-col w-5/6 h-full border-blue-700 border-2 border-dashed rounded-lg p-5 space-y-5" > <template #item="{element}"> <FormBuilder :component="element" @update="update" /> </template> </VueDraggableNext> </div> </template> <script setup> import FormBuilder from "~~/components/dynamic-components/FormBuilder.vue"; import ComponentPalette from "~~/components/form-builder/ComponentPalette.vue"; import { v4 as uuidv4 } from "uuid"; const form = reactive({ formId: "abcd-1234", formName: "User Registration", children: [], }); const isDragOver = ref(false); </script> <style scoped></style>

una vez que ejecute el proyecto, obtendré los siguientes errores:

 [Vue warn]: A plugin must either be a function or an obj ect with an "install" function. [Vue warn]: Failed to resolve component: VueDraggableNex t If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCust omElement.

¿Cómo puedo usar este complemento vue correctamente en un proyecto nuxt3?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

tienen algunas diferencias entre un Vue Plugin y un Nuxt Plugin. Lo que está tratando de hacer es crear un complemento Nuxt para usar un componente Vue. Entonces, para hacer esto, debe actualizar su código a:

 import { VueDraggableNext } from "vue-draggable-next"; export default defineNuxtPlugin((nuxtApp) => { nuxtApp.vueApp.component("draggable", VueDraggableNext); });

La diferencia es la forma en que registra el componente en vueApp. Además, con este cambio, deberá actualizar el nombre del componente dentro de la plantilla html a <draggable>

Aquí sigue algunos enlaces útiles si quieres saber más:

  • https://vuejs.org/guide/components/registration.html#global-registration
  • https://v3.nuxtjs.org/guide/directory-structure/plugins
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!