materialUI是封装起来的组件,如何下手改呢?
例如,把这个……
改成这样……
import React from 'react';
import Tabs from 'material-ui/lib/tabs/tabs';
import Tab from 'material-ui/lib/tabs/tab';
import Slider from 'material-ui/lib/slider';
const styles = {
headline: {
fontSize: 24,
paddingTop: 16,
marginBottom: 12,
fontWeight: 400,
},
};
function handleActive(tab) {
alert(`A tab with this route property ${tab.props.route} was activated.`);
}
const TabsExampleSimple = () => (
Tab One
This is an example tab.
You can put any sort of HTML or react component in here. It even keeps the component state!
Tab Two
This is another example tab.
Tab Three
This is a third example tab.
);
export default TabsExampleSimple;
看着这些代码,一筹莫展……
请告知思路,谢谢~
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
组件是封装(屏蔽)了一些东西,开放(扩展)了一些东西,如果这个不是组件提供的可选样式,那么你是不好改的。你可以改的是颜色之类的。
所以你的需求,要不找找是否有其他更适合的组件,例如list, menu等;要不自己去创建新的组件
今天无聊随手答一波:
Material UI 的所有样式均采用了 CSS in JS 来做,这意味着所有的样式都是 inline(内联)的,有着非常高的优先级。好在,Material UI 中大部分组件都暴露了 style 甚至 childComponentStyle 这样的“接口”(即 props)供你使用,具体可以参见官方文档。
另外,对于少数 Material UI 没有做好接口又非要 override 的情况,可以强行用选择器 + !important 侵入,但是非常不推荐: