I am building a system that can generate HTML from JSON.
The following JSON
"type": "span",
"content": [
{
"type": "span",
"content": [
{
"type": "div",
"content": []
}
]
}
]
Should generate The following html
<span>
<span>
<div></div>
</span>
</span>
I have made this to convert the JSON
export default {
name: 'HTMLElement',
props: {
data: {
type: Array,
default: []
}
},
render(createElement) {
return createElement(
this.data.type,
createElement(
HTMLElement,
{
props: {
data: this.data.content
}
}
)
);
}
}
The propertie data is the JSON only than parsed to a Object
When I am running this code I get the following error
Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
Has anyone any idea of a better solution or a fix to this situation ?
Thank you in advance,
Jeroen
HTMLElement,tonew HTMLElement,HTMLElement, also, arrays don;t have thetype&contentproperties