const [count, setCount] = useState(0 ) useEffect(() => { document.title = `You clicked ${count} times`; },[count]); return ( <p>次数:{count}</p> <button onClick={() => { setCount(count + 1 ) }} >点击</button>
useEffect Hook 可看做 componentDidMountcomponentDidUpdate 和 componentWillUnmount 这三个函数的组合。
第一个参数为函数,可以在此时返回需要清理的内容,相当于componentWillUnmount。
第二个参数可传可不传。空数组表示只渲染一次,相当于componentDidMount钩子函数;非空数组,当数组里的值发生改变则会重新渲染;不填,则每次都会渲染。
JAVA定义字节流 java字节输出流

此抽象类,是表示输出字节流的所有类的超类。操作的数据都是字节,定义了输出字节流的基本共性功能方法。 • 字节: 这样流每次只操作文件中的1个字节 • 流对象:操作文件的时候,自己不做依赖操作系统