如何让 Vue 3 渲染函数 h() 输出 html

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

我正在使用 Vue 3 渲染函数,无法确定如何在模板中渲染 HTML。

我试过这个:

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

但它在页面上输出 html 标签 <strong>Bold</strong> 而不是 Bold

有谁知道如何让渲染函数渲染HTML?

根据h() arguments,我认为渲染函数不能直接在子参数中渲染HTML,你需要转移到另一个渲染函数,比如

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

但是你可以在 props 参数中设置 innerHTML 来实现它:

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