Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
Passing HTML or Components to the Vue Plugin

I have created the basic Vue component which is as follow.

<template>
  <div class="example">
    /* here render the component or HTML passed by pluing */
  </div>
</template>

<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
  name: 'Example',
});
</script>

Now I need to create a plugin that will render any HTML or Component passed to the Example.I know the basic syntax of plugins and how to use them in the Vue but don't know how to do this task since I am a newbie to Vue.

export default {
    install(vue, opts){ 
      /* how to take the component or HTML and pass to `Example` Component */
    }
}

I need to implement these in vue2.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use a slot to render an arbitrary HTML inside any of your components.

Your Example Component:

<template>
  <div class="example">
    <slot />
  </div>
</template>

<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
  name: 'Example',
});
</script>

Then use it like this:

<template>
  <example>
    <div>Render me inside the slot</div>
  </example>
</template>

And it will result in the following rendered HTML:

<div class="example">
  <div>Render me inside the slot</div>
</div>

Then in you plugin you can use your Example component and pass any html you want to it

Update: this how your plugin might look like. Just create a global component inside of it

import Vue from 'vue'

const ExamplePlugin = {
  install(Vue){
    Vue.component('Example', {
      name: 'Example',
      template: '<div class="example"><slot /></div>'
    })
  }
}

Then you can Vue.use(ExamplePlugin) and Example component will be available globally in your application

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda