I am working on a simple component that displays an HTML string:
<template>
<v-list-item-content v-html="html_string">
</template>
<script>
export default {
name: "HtmlRenderer",
props: ['html_string']
</script>
The HTML content is fetched from an API in the parent component and may include basic HTML elements such as <p>
and <blockquote>
.
I want to manipulate the DOM of this HTML string by performing the following actions:
- Locate each
<blockquote>
tag and insert a button before it (there could be zero or more instances) - Create a button that toggles the
.active
class for the corresponding<blockquote>
How can I achieve these steps within the lifecycle of a VUE component? Is it possible to call a function defined in the methods section of the component from the injected <button>
?
Any insights or suggestions would be greatly appreciated.