如果有错误,欢迎留言指教~ Q_Q
classnames()
可以传入N个 string 或 object,根据 component 的 state 或是 props 来改变状态,就可以串成想要显示的 className 们
// 可以传入 string 或是 object
classNames('foo', { bar: true });
// => 'foo bar'
// 可以传入 array
// object 的 value 如果是 falsy 值,则不会显示
let arr = ['b', { c: true, d: false }];
classNames('a', arr);
// => 'a b c'
// 也可以组合模板文字
let buttonType = 'primary';
classNames({ [`btn-${buttonType}`]: true });
// => 'btn-primary'
import cx from 'classnames';
const App = ({ children }) => {
const [isShowArrow, setIsShowArrow] = useState(false);
return (
<div className={cx('arrow', { 'is-show': isShowArrow })}
{children}
</div>
);
}
import cx from 'classnames';
const App = ({ children }) => {
const leftArrowClass = cx(
'left-arrow',
{ hidden: !hasLeftArrow }
);
return (
<div className={leftArrowClass}
{children}
</div>
);
}
import classnames from 'classnames/bind';
import { tabHeaderStyle } from './Tab.style';
const cx = classnames.bind(tabHeaderStyle);
const App = ({ name }) => {
return (
<a className={cx('tab', {'isActive': true })}>
{name}
</a>
);
}
帮你简化需要判断过程中的值是否存在,如果中间属性为 null 或未定义,则 return
import idx from 'idx';
const news = idx(data, _ => _.data.items) || {};
const quotes: IAdAndNewProps[] = idx(data, _ => _.data.items.data);
这次要来谈的是Rust的测试框架,并且重新调整目录架构。 撰写测试 Rust本身就自带测试框架,无须...
昨天介绍了各种选择器,今天介绍伪类及伪元素样式设定,可以让画面有更多的样式变化,也减少html co...
自我介绍 这是我第一次参加铁人赛,内容可能很菜,希望大家多多包涵 动机 因为平常满常使用其他人制作的...
两个很棒的NIST准则: .NIST SP 800-16 .NIST SP 800-50 -IT安全...
思路 用dps从start点走一遍,然後检查end点有没有finish。 程序码 class Sol...