确保使用React Bootstrap和Hyperstack Router选择正确的导航项目的最佳方法是什么?
我知道我可以使用Link方法,但是我想使用特定的Bootstrap Nav项。
有没有任何人都可以分享的好例子?
发布于 2019-04-14 18:07:46
React路由器实际上是自动处理这个问题的!我已经在我的一个应用程序中使用了这个,也许它可以帮助我获得灵感:
class BS < Hyperstack::Component::NativeLibrary
# subclasses of Hyperstack::Component::NativeLibrary
# are wrappers around JS component libraries.
# once imported BS acts like an ordinary ruby module
imports 'ReactBootstrap'
endclass App < HyperComponent
include Hyperstack::Router
include Hyperstack::Router::Helpers
ROUTES = {
'/' => ['Home', Home],
'/overview' => ['Overview', Overview]
}
render do
DIV {
H1 { "Hello there from Hyperstack!" }
BS::Nav(variant: 'pills') {
ROUTES.each do |k, v|
BS::Nav.Item() {
NavLink(k, class: 'nav-link', exact: true) { v[0] }
}
end
}
ROUTES.each do |k, v|
Route(k, mounts: v[1], exact: true)
end
}
end
endhttps://stackoverflow.com/questions/55674018
复制相似问题