[Vuejs]-Vue – Export Rendered HTML from v-html component

1👍

You should use a template ref for this:

<script setup>
import { utils } from 'xlsx';

const htmlParse = utils.sheet_to_html(worksheet)

function classModifier(event){
    const clickedElement = event.target
    clickedElement.classList.toggle("my-class")
}

const div = ref(null);

// later on in some kind of save callback or whatever
div.value.innerHTML

</script>

<template>
   <div @click="classModifier" v-html="htmlParse" ref="div"></div>
</template>

Leave a comment