如何使用JSX创建非空注释节点? [英] How to create a non-empty comment node using JSX?

查看:61
本文介绍了如何使用JSX创建非空注释节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有运气就尝试了以下方法,想产生一个<!-Baz-> 评论节点:

I've tried the following with no luck, wanted to produce a <!-- Baz --> comment node:

export default {
  render() {
    return (
      <strong>
        Foo
        {/* Baz */}
      </strong>
    )
  },
}

推荐答案

虽然严格来说不是JSX,但我没有更好的方法来实现这一点:

Although it's not strictly JSX, I haven't better way to achieve this:

import { Comment, h } from 'vue'

export default {
  render() {
    return (
      <strong>
        Foo
        {h(Comment, 'Baz')}
      </strong>
    )
  },
}

这篇关于如何使用JSX创建非空注释节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆