当前位置: 首页 > news >正文

绍兴专业网站建设电子商务公司招聘

绍兴专业网站建设,电子商务公司招聘,wordpress商城案例,投资做网站利润分析自定义组件的时候往往需要传 children#xff0c;由于写法比较多样#xff0c;我就总结了一下。 方案列表 1. 类组件1.1 类组件#xff0c;不使用解构1.2 类组件#xff0c;使用解构 2. 函数组件2.1 函数组件#xff0c;不使用解构2.2 函数组件#xff0c;外部解构2.3 函…自定义组件的时候往往需要传 children由于写法比较多样我就总结了一下。 方案列表 1. 类组件1.1 类组件不使用解构1.2 类组件使用解构 2. 函数组件2.1 函数组件不使用解构2.2 函数组件外部解构2.3 函数组件内部解构 3. 普通函数3.1 普通函数内部解构3.2 普通函数外部解构3.3 普通函数外部解构不使用自定义Type3.4 普通函数不使用解构不使用自定义Type 调用及展示 要自定义的组件是这样的 其中包含一个 title 和一个 children。 定义一个后面要用到的 Props: /** 定义属性对象* - title: 标题* - children: 子组件*/ type Props {title: string;children?: React.ReactNode; };1. 类组件 1.1 类组件不使用解构 class ClassComponent1 extends ComponentProps {render(): ReactNode {return (div style{{ backgroundColor: red }}h2{this.props.title}/h2{this.props.children}/div);} }1.2 类组件使用解构 class ClassComponent2 extends ComponentProps {render(): ReactNode {// 解构赋值const { title, children } this.props;return (div style{{ backgroundColor: red }}h2{title}/h2{children}/div);} }2. 函数组件 2.1 函数组件不使用解构 const FunctionComponent1: React.FCProps (props) {return (div style{{ backgroundColor: orange }}h2{props.title}/h2{props.children}/div); };2.2 函数组件外部解构 const FunctionComponent2: React.FCProps ({ title, children }) {return (div style{{ backgroundColor: orange }}h2{title}/h2{children}/div); };2.3 函数组件内部解构 const FunctionComponent3: React.FCProps (props) {// 解构赋值const { title, children } props;return (div style{{ backgroundColor: orange }}h2{title}/h2{children}/div); };3. 普通函数 3.1 普通函数内部解构 function NormalFunction1(props: Props) {// 解构赋值const { title, children } props;return (div style{{ backgroundColor: yellow }}h2{title}/h2{children}/div); }3.2 普通函数外部解构 function NormalFunction2({ title, children }: Props) {return (div style{{ backgroundColor: yellow }}h2{title}/h2{children}/div); }3.3 普通函数外部解构不使用自定义Type function NormalFunction3({title,children, }: {title: string;children?: React.ReactNode; }) {return (div style{{ backgroundColor: yellow }}h2{title}/h2{children}/div); }3.4 普通函数不使用解构不使用自定义Type function NormalFunction4(props: { title: string; children?: React.ReactNode }) {return (div style{{ backgroundColor: yellow }}h2{props.title}/h2{props.children}/div); }调用及展示 export default class ChildrenPage extends Component {render() {return (div style{{ padding: 20px }}h1组件传children/h1ClassComponent1 title类组件不使用解构p这里是children/p/ClassComponent1ClassComponent2 title类组件使用解构p这里是children/p/ClassComponent2FunctionComponent1 title函数组件不使用解构p这是里children/p/FunctionComponent1FunctionComponent2 title函数组件外部解构p这是里children/p/FunctionComponent2FunctionComponent3 title函数组件内部解构p这是里children/p/FunctionComponent3NormalFunction1 title普通函数内部解构p这里是children/p/NormalFunction1NormalFunction2 title普通函数外部解构p这里是children/p/NormalFunction2NormalFunction3 title普通函数外部解构不使用自定义Typep这里是children/p/NormalFunction3NormalFunction4 title普通函数不使用解构不使用自定义Typep这里是children/p/NormalFunction4/div);} }
http://www.huolong8.cn/news/47017/

相关文章:

  • 游戏网站设计模板可编辑wordpress主题
  • 网站备案怎么改广告推广平台赚取佣金
  • 做医采官方网站网站建设mus18
  • 企业网站规划案例企业自己怎么做网站推广
  • 南宁网站制作工具如何管理wordpress网站模板下载
  • 做自己的网站怎么赚钱经营地址怎么在国税网站做更改
  • 免费查企业app排行榜网络优化排名培训
  • 分析对手网站的优化方法赣icp网站建设
  • 国外网站开发技术现状阿里巴巴与慧聪网网站建设对比
  • 网站建设可以自学吗网络规划设计师教程最新版
  • 做线下活动的网站做网站的知名公司
  • 动态ip可以做网站域名检测
  • 企业大型网站开发需要多少钱广西玉林网站建设正规公司
  • 旌阳移动网站建设加强文明网站建设
  • 洛阳制作网站的公司顺义公司网站建设
  • wordpress开放哪个端口企业网站优化怎么做
  • 杭州设计公司网站排名辽宁建设工程信息网网站
  • 淘宝上有做网站的吗wordpress用户名怎么设置密码
  • 无锡网站制作启电商网站建设 平台
  • 网站免费建站ppa如何建设一个不备案的网站
  • 网站建设教程网页泾县网站建设
  • 浙江网站建设 seowordpress4.1.12 漏洞
  • 网站建设大作业厦门微信网站建
  • 郑州网站seo多少钱seo培训中心
  • linux做网站网络课堂网站建设京icp备
  • 做国外网站青岛外贸网站运营哪家好
  • 用文件传输协议登录网站中小型网站建设怎么样
  • 国外做设备网站wordpress 做的官网
  • 如何在vps上建设网站vs建设网站
  • o2o苗木网站建设百度网址入口