CUGreen
CUGreen

Reputation: 3186

How to get Vue 3 render function h() to output html

I am using Vue 3 render function and cannot work out how to render HTML in the template.

I have tried this:

h('span', {}, '<strong>Bold</strong>');

But it outputs the html tags <strong>Bold</strong> on the page rather than Bold.

Does anyone know how to get the render function to render HTML?

Upvotes: 2

Views: 6540

Answers (1)

Ryan
Ryan

Reputation: 20116

According to h() arguments,I think the render function could not render HTML directly in the children argument, you need to transfer to another render function like

return h('span', {}, [h('strong', 'Bold')]);

But you could set innerHTML in the props argument to make it:

return h('span', {
    
    innerHTML:'<strong>Bold</strong>'
    
},[]);

Upvotes: 3

Related Questions