import React  from 'react';
import { openLink } from '@/utils';
import styles from './index.less';

const Link=(props)=>{
  const {children,className='',onClick,href='',target=''} = props;

  const onLink=()=>{
    if(href){
      if(target=='_blank'){
        openLink(href);
        // window.open(href);
      }else{
        location.href=href;
      }
      return;
    }
    if(onClick)onClick();
  }
  return (
    <span onClick={onLink} className={`${styles.linkWrap} ${className}`}>{children}</span>
  )
}
export default React.memo(Link);