美文网首页
类型演算之Pick

类型演算之Pick

作者: percykuang | 来源:发表于2020-06-02 08:41 被阅读0次

    React中的应用

    巧用Pick给props以默认值

    interface IProps {
      a: string
      b: string
    }
    
    class Test extends React.Component<IProps> {
      static defaultProps: Pick<IProps, 'a'> {
        a: '123'
      }
    }
    
    class User extends React.Component {
      render() {
        return <Test b='123' />
      }
    }
    

    相关文章

      网友评论

          本文标题:类型演算之Pick

          本文链接:https://www.haomeiwen.com/subject/mxuyzhtx.html