Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
how to render custom vis.js item templates using vue 3

Problem: Visjs docs shows examples of how to use react templates in visjs for customs items but not for vue.

Solution: we need to use vue render functions to render the template while passing props to the child and emitting events back to the parent.

I solved the issue where groupTemplate don't want to load. (answer updated)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

So making the render function async seems to solve it :D I will just leave this here for future people. Struggled all day trying to get the group template to work. I would have thought defineAsyncComponent would solve it but it did not quite budge, seems just asynchronously loading the render function does the trick.


import { render, h } from 'vue';

const itemTemplate = async (item, element) => render(h(bar, {
  onDelete: (ev) => {
    items.remove(item.id)
  },
  item,
}), element
)


const groupTemplate = async (group, element) => render(h(groupbar, {
  onHide: () => {
    groups.update(group.id, { hidden: true })
  },
  group,

}), element
)

const options = ref({
  template: (item, element) => {
    if (!item) return;
    return itemTemplate(item, element);
  },
  groupTemplate: (group, element) => {
    if (!group) return;
    return groupTemplate(group, element);
  }

})

template


<template>
  <div class="group-container">
    <button @click="emits('hide', group.id)">hide</button>
    {{ group.content }}
  </div>
</template>

<script setup>
import { watch } from 'vue';


const emits = defineEmits(['hide']);

const props = defineProps({
  group: {
    type: Object
  }
})

</script>


<style>
.group-container {
  background: red;
}
</style>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda