div
当用户单击链接时,我试图在同一页面上呈现 a 。
我的 HTML 页面:
<div class="stores">
<h1>Stores</h1>
<ul class="stores">
<li><a href="#" onClick={this.onClick} >Store A</a></li>
<li>Store B</li>
<li>Store C</li>
</ul>
</div>
我的components/store.js.jsx
:
var Store = React.createClass({
getInitialState: function() {
return { showStore: false };
},
onClick: function() {
this.setState({ showStore: true });
},
render: function() {
return(
<div className="row account stores" style={{display: { this.state.showStore ? 'block' : 'none'} }}>
<div>a lot more divs</div>
</div>
);
}
});
但我得到一个:
语法错误:未知:意外的令牌
对于这一行:
style={{display: { this.state.showStore ? 'block' : 'none'} }}
如何有条件地嵌套在样式中?