新的react-router语法使用该Link
组件在路由周围移动。但是,如何将其与material-ui
?
就我而言,我将标签用作主要的导航系统,因此从理论上讲,我应该具有以下内容:
const TabLink = ({ onClick, href, isActive, label }) =>
<Tab
label={label}
onActive={onClick}
/>
export default class NavBar extends React.Component {
render () {
return (
<Tabs>
<Link to="/">{params => <TabLink label="Home" {...params}/>}</Link>
<Link to="/shop">{params => <TabLink label="shop" {...params}/>}</Link>
<Link to="/gallery">{params => <TabLink label="gallery" {...params}/>}</Link>
</Tabs>
)
}
}
但是在渲染时,material-ui会引发一个错误,该错误的子级Tabs
必须是Tab
组件。可能的方式是什么?如何管理isActive
标签的道具?
提前致谢
我的老师帮助我使用了React Router 4.0的withRouter来包装Tabs组件,以启用类似这样的历史记录方法:
import React, {Component} from "react";
import {Tabs, Tab} from 'material-ui';
import { withRouter } from "react-router-dom";
import Home from "./Home";
import Portfolio from "./Portfolio";
class NavTabs extends Component {
handleCallToRouter = (value) => {
this.props.history.push(value);
}
render () {
return (
<Tabs
value={this.props.history.location.pathname}
onChange={this.handleCallToRouter}
>
<Tab
label="Home"
value="/"
>
<div>
<Home />
</div>
</Tab>
<Tab
label="Portfolio"
value="/portfolio"
>
<div>
<Portfolio />
</div>
</Tab>
</Tabs>
)
}
}
export default withRouter(NavTabs)
只需将BrowserRouter添加到index.js,就可以了。
问题内容: 我在项目中一直使用这两个工具,有时我发现需要在Bootstrap组件和UI显示中使用Material UI组件,这与我期望的一样。有人建议我不要使用这种方法。既然两者都在使用网格并且可以灵活使用,那有什么理由吗? 问题答案: 我倾向于冗长,因此我将简洁的答案放在这里: 结论: 谁说不好用两者可能只是在表达自己的观点,实际上说不好用两者在设计时确实缺乏上下文。@ user3770494提
Material UI 是一套实现了 Google 的 Material Design 全新设计语言的 CSS 框架。Material UI 提供了 npm 包的形式,使用示例: /** * @jsx React.DOM*/var React = require('react'), mui = require('material-ui'), PaperButton = mui.PaperBut
MUI Quickly build beautiful React apps. MUI is a simple and customizable component library to build faster, beautiful, and more accessible React applications. Follow your own design system, or start w
Nativescript Material Components Build beautiful, usable products using Material Components for NativeScript. Installation Android Ensure your Android Theme is inheriting from MaterialComponents.Insid
jQuery UI Tabs Paging 是一个用来对太多的 Tab 进行分页显示的 jQuery 插件,如下图所示: 需要的环境支持: jquery-1.3.2.js jQuery UI 1.7.2 - ui.core.js and ui.tabs.js 在线演示
问题内容: 可以说我希望每个组件都具有默认的道具吗? 问题答案: 此处的文档位于: https //material-ui.com/customization/globals/#default-props 这是如何执行此操作的示例: