常用npm包

  1. postcss-pxtorem :px自动换算为rem
    如果px写成PX、Px等,不会转rem
  2. react-media-hook2:屏幕适配
import React from 'react';
import useMedia from 'react-media-hook2';

const Layout: React.FC = ({ children }) => {
  const [matches] = useMedia({ query: '(min-width: 1920px)' });
  return <div className={matches ? 'pc' : 'mobile'}>{children}</div>;
};

export default Layout;
  1. classnames
<div className={ClassNames("theme-bg",{[`${this.state.theme}-img`]:true})}/>

classnames的使用
github

4.stylelint

 "devDependencies": {
	"stylelint": "9.10.1",
	"stylelint-config-css-modules": "^1.4.0",
	"stylelint-config-prettier": "^5.0.0",
	"stylelint-config-rational-order": "^0.1.0",
	"stylelint-config-standard": "^18.3.0",
	"stylelint-declaration-block-no-ignored-properties": "^1.1.0",
	"stylelint-order": "^2.2.1",
}
posted @ 2020-03-28 20:17  知知为之之  阅读(478)  评论(0)    收藏  举报