这些功能比较简单,都是通过reacthooks和reactclass来实现的。如果你喜欢它,请喜欢它。React实现watchreacthook并实现watchfunctionuseWatch 2333 2333 {this.newCount}

这些功能比较简单,都是通过reacthooks和reactclass来实现的。如果你喜欢它,请喜欢它。React实现watchreacthook并实现watchfunctionuseWatch 2333 2333 {this.newCount});}}react实现插槽(slot)reacthooks版本functionChild({children}:{children:React.ReactNode}){return(child{children});}exportdefaultfunctionSlot(){return();}react类写法classChildextendsReact.Component{render(){const{children}=this.props;返回(孩子{孩子});}}classNameextendsReact.Component{constructor(props:React.FC){super(props);}render(){return({getCount});}react类的写法原理是每一个setState都会触发render,然后重新获取newCountclassNameextendsReact.Component{state={count:0};构造函数(道具:React.FC){超级(道具);}getnewCount(){返回这个.state.count+1;}render(){return();}}react实现v-modelreacthooksversioninterfaceformProps{name?:string;age?:string;}exportdefaultfunctionModel(){const[form,setForm]=useState);}react类写法interfaceformProps{name?:细绳;age?:string;}classModelextendsReact.Component);}}react实践cssscopedcss模块#index.module.css.app{color:aqua;flex:1;}#Css.tsximportStylefrom"./index.module.css";exportdefaultfunctionCss(){return();}cssinjs(emotion)安装npmi@emotion/styled@emotion/react使用/*@jsxImportSource@emotion/react*/importstyledfrom"@emotion/styled";import{css}来自“@emotion/react”;从“./index.module.css”导入样式;constbase=css`color:#ee298c;`;constContainer=styled.div`padding:23px;&:hover{颜色:${(props)=>props.color};}`;导出默认函数Css(){return(