import { AtButton } from 'taro-ui'; import Taro, { FC } from '@tarojs/taro'; import { ButtonProps } from '../../../@types/button'; const ButtonTypes = ['error', 'warning']; const isButtonType = (x: any) => ButtonTypes.includes(x); const Button: FC = props => { const { className, loading, customtype = '' } = props; let cn = className; if (customtype && isButtonType(customtype)) { cn = className ? `${className} ${customtype}` : `${customtype}`; } // 拦截按钮单击事件,遇到异步方法传入并触发事件时自动进入loading状态 return ( {props.children} ); }; export default Button;