前端框架(react+umi+dva+ant design pro )攻克: 二、react 父子组件通信(二)
发布日期:2021-05-12 23:54:09 浏览次数:10 分类:精选文章

本文共 2076 字,大约阅读时间需要 6 分钟。

���������������������������������

���React������������������������������������������������������������������������������������������������������������������������������������������������props������������������������������������������������������������������

���������������������������������

  • ������������������������������������
  • ��������������� JSX ��������� {���������} ���������������������������������
  • ��������������� this.props ������������������������
  • ���������

    • ������������
    function ParentComponent() {  const valueToPass = 'Hello from Parent';  return (    
    );}
    • ������������
    function ChildComponent props ({ valueProp }) {  return (    

    ������������������{valueProp}

    );}

    ���������������������������������

    ������������������������������������������������������������������������������������������������������������������������������������������������������������������props���������������������������������������������������������������������������������������������������������������

    ���������

  • ������������������������������������������������������
  • ��������������� JSX ���������������������������������
  • ���������������������������������������������������������������
  • ���������

    • ������������
    function ParentComponent() {  const [result, setResult] = useState(null);  const handleData = (data) => {    setResult(data);    console.log('���������������������', data);  };  return (    
    );}
    • ������������
    function ChildComponent props ({ handleDataFunction, otherProp }) {  const processResult = () => {    const finalData =-process otherProp;    handleDataFunction(finalData);  };  return (    
    );}

    ������������

    ������������������������������������������������������������������props���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

    上一篇:前端框架(react+umi+dva+ant design pro )攻克: 三、umi 知识点
    下一篇:前端框架(react+umi+dva+ant design pro )攻克: 二、react(一)

    发表评论

    最新留言

    很好
    [***.229.124.182]2025年04月05日 19时16分58秒