React的函数式组件

72 阅读1分钟

函数组件的基本定义

import { FC } from 'react';
import {View} from "@tarojs/components";
import { AtDivider } from 'taro-ui'

import './index.scss'

interface TitleType {
  title?: string;
  fontColor?:string,
  lineColor?:string
}

const Index: FC<TitleType> = (props) => {
  return (
    <View><AtDivider content={props.title} fontColor={props.fontColor} lineColor={props.lineColor} /></View>
  );
};

Index.defaultProps = {
  title:'标题',
  fontColor:'#333',
  lineColor:'#eee'
}

export default Index