我可能错过了一些东西,但是在这里.如果我有:
var Swoosh = React.createClass({ render: function() { return ( <div className="swoosh"> Boom. </div> ); } }); React.renderComponent( <Swoosh />,document.getElementById('content') );
我可以将道具设置为挂载点(其中id =’content’)的属性吗?
<div id='content' foo='alice' bar='has' bav='a cat' /> <!-- have foo,bar & bav available as props in <Swoosh />? -->
不,当然你可以做:
var container = document.getElementById('content'); React.renderComponent( <Swoosh foo={container.getAttribute('foo')} bar={container.getAttribute('bar')} bav={container.getAttribute('bav')} />,container );
(或者如果你想使用像https://stackoverflow.com/a/5282801/49485这样的属性dict,那么你可以做Swoosh(属性)).
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。