似乎可以在聚合物网络组件中使用 react ,但我找不到一个有效的例子,只有this,但它似乎已经过时了。
HTML
<link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html" />
<polymer-element name="my-polymer" constructor="" attributes="name">
<template>
<P>I AM {{name}}</P>
<div id="reactContainer"></div>
</template>
<script type="text/jsx">
/** @jsx React.DOM **/
Polymer('my-polymer', {
created: function(){},
ready: function(){},
attached: function(){},
domReady: function(){
React.renderComponent(<MyReact name="REACT INSIDE POLYMER"/>, this.$.reactContainer);
},
detached: function(){},
attributeChanged: function(attrName, oldVal, newVal) {}
});
</script>
</polymer-element>
<my-polymer name="POLYMER"></my-polymer>
JS
/** @jsx React.DOM */
var MyReact = React.createClass({
render: function() {
return (
<p>I AM {this.props.name}</p>
);
}
});