2
我想實現反應路由器到我的應用程序,但我遇到了一個問題,我有一些「鏈接」,顯示「模式」對話框,但反應路由器將他們視爲路線,並將我送回我的「主頁」頁面如何忽略React路由器中的鏈接?
<a href="#" onClick={() => this.props.Show(true) }><i className="fa fa-plus" aria-hidden="true">
路由器
ReactDOM.render(
<Provider store={store}>
<Router history={hashHistory}>
<Route path="/" component={Layout}>
<IndexRoute component={Home}></IndexRoute>
<Route path="app" name="app" component={App}></Route>
</Route>
</Router>
</Provider>,
document.getElementById('root')
);
這種聯繫是在 「應用程序」 組件的組件。
編輯
我有這個現在
return (
<a href="#" id="add-new-storage-item-btn" className={addNewItemClasses} onClick={(event) => this.setAddStorageItemModal(event) }><i className="fa fa-plus" aria-hidden="true"> Add New Item</i></a>
);
setAddStorageItemModal(event)
{
this.props.setAddStorageItemModal(true);
event.stopPropagation();
}
我試圖把event.stopPropagation作爲一線,但不起作用。
啊對,我試圖返回false;但這似乎沒有工作,所以我甚至沒有嘗試這個,但它確實有效。 – chobo2
你也可以將'onClick()'分配給不是錨定標記的元素 –
奇怪的是,它認爲它正在工作,但現在它似乎並沒有工作。 – chobo2