有什么方法可以在不使用 HTML 正文中的 id 标签的情况下将 Semantic-UI 侧边栏渲染到 React App 中?我想避免在 HTML 正文中将 React 组件渲染为 tagis,例如 NOT using: <div id="some-name"></div>
。
我正在使用 Meteor 但不应该对这个问题产生影响,这似乎是 React & Semantic UI 特有的。
下面的代码在浏览器控制台中给出了以下错误:
Sidebar: Had to add pusher element. For optimal performance make sure body content is inside a pusherSidebar:
Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag <div class="ui sidebar inverted vertical menu left uncover animating visible" data-reactid=".0.0">…</div>
Warning: ReactMount: Root element has been removed from its original container. New container:
index.html 语义边栏1
应用程序.js
// App component - represents the whole app
App = React.createClass({
showSideMenu() {
$('.ui.sidebar')
.sidebar('toggle');
},
render() {
return (
<div>
<div className="ui sidebar inverted vertical menu">
<a className="item">
1
</a>
<a className="item">
2
</a>
<a className="item">
3
</a>
</div>
<div className="pusher">
<button onClick={this.showSideMenu} className="ui button">Test MyModalDlgOne</button>
<p />
React App.
</div>
</div>
);
}
});
if (Meteor.isClient) {
// This code is executed on the client only
Meteor.startup(function () {
// Use Meteor.startup to render the component after the page is ready
// React.render(<App />, document.getElementById("render-target"));
React.render(<App />, document.body);
});
}