I created a project with Vue CLI and now I need slot value inside the mounted function.
I can access slot with this.$slots.default and I got VNode array.
Now I need to convert VNode array into the HTML string like for example:
const html = `<p><strong>Lorem</strong> ipsum</p>`;
My currently code looks like this:
<TestComponent field="website" :data="document">
<p><strong>Lorem</strong> ipsum</p>
</TestComponent>
<template>
<div class="test">
<p>lorem ipsum</p>
</div>
</template>
<script>
export default {
props: ["field", "data"],
data() {
return {
editor: null,
};
},
mounted() {
if (this.$slots.default) {
const html;
console.log(this.$slots.default);
}
},
};
</script>