Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document 使用 jsx 开发,如何友好支持 script 代码 #197

Closed
desenmeng opened this issue Feb 20, 2020 · 1 comment
Closed

document 使用 jsx 开发,如何友好支持 script 代码 #197

desenmeng opened this issue Feb 20, 2020 · 1 comment

Comments

@desenmeng
Copy link
Contributor

<script>
    const  test = {
       title: "test title"
   }
</script>

构建时,会被转义
如果使用 dangerouslySetInnerHTML 与其他模板相比,体验太不友好
希望可以给一个方案

@chenjun1011
Copy link
Contributor

chenjun1011 commented Feb 27, 2020

不能将 JSX 完全等同于模板语言。在 JSX 里,这个限制很难去除,比如上面示例代码里的 {} 在 JSX 编译的时候就会被认为里面的内容是表达式。所以只能通过 dangerouslySetInnerHTML 来实现这类需求。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants