gpt4 book ai didi

javascript - ReactJS/jQuery 获取 HTML

转载 作者:行者123 更新时间:2023-11-28 15:47:24 25 4
gpt4 key购买 nike

我只想从 ReactJS 组件获取 HTML。我使用需要一些 HTML 作为参数的 jquery 模块。我在应用程序的其余部分使用 Coffeescript 和 ReactJS。

Action = React.createClass
render: -> [...]

componentDidMount: ->
$(myJQueryModule).action(
html: $(@props.html).html()
)

Action
html: React.DOM.span {className: "test"}, "test of text"

顺便说一句,这不起作用,我很难理解为什么。有人可以帮忙吗:)?

最佳答案

组件不会渲染为这样的文本,您可能想使用 http://facebook.github.io/react/docs/top-level-api.html#react.rendercomponenttostring

但是不会有任何 React 集成和事件等,因此您最好在字符串中使用普通 HTML 来提供给 jquery。

关于javascript - ReactJS/jQuery 获取 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21831381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com