我正在尝试传递一个Handlebars模板,以便this.props.children使用以下JSX代码段进行处理:
<MyComponent>
My address is {{address}}.
</MyComponent>
Run Code Online (Sandbox Code Playgroud)
结果是Uncaught ReferenceError: address is not defined.
解决方法是使用类似的东西:
<MyComponent>
<span content="My address is {{address}}."></span>
</MyComponent>
Run Code Online (Sandbox Code Playgroud)
然后使用this.props.children.props.content.这是我发现基本上逃避{{address}}被JSX解释为插值的唯一方法.
有没有一种简单的方法来逃避JSX中的花括号?