Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@_nu/react-avatar

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@_nu/react-avatar

react avatar

Source
npmnpm
Version
0.3.2
Version published
Weekly downloads
14
-78.46%
Maintainers
2
Weekly downloads
 
Created
Source

@_nu/react-avatar

npm packagenpm downloadsjsdelivrgithub
npm packagenpm downloadsjsdelivrgithub

安装

$ npm install @_nu/react-avatar

二次封装

/* @/components/Avatar/index.js */
import Avatar from "@_nu/react-avatar";

// 这里编写自定义的样式
import './style.css';

export default Avatar;

使用

import React from 'react';
import Avatar from "./components/Avatar";
import imgAvatar from '../avatar.jpg';

const AvatarDefault = ({ className = null }) => (
  <svg
    viewBox="0 0 1024 1024"
    xmlns="http://www.w3.org/2000/svg"
    className={className}
  >
    <path d="M512 64a448 448 0 1 0 448 448A448 448 0 0 0 512 64zm0 160a144 144 0 1 1-144 144 143.68 143.68 0 0 1 144-144zm256 573.44a381.76 381.76 0 0 1-512 0v-18.56A166.4 166.4 0 0 1 416 608h192a166.72 166.72 0 0 1 160 169.92v19.52z" />
  </svg>
);

const Page=()=>{
    return (
     <div>
      <Avatar src={imgAvatar} alt="hello" size={24} />
      <Avatar src={imgAvatar} alt="hello" size={40} />
      <Avatar src={imgAvatar} alt="hello" size={32} />
      <Avatar src={imgAvatar} alt="hello" size="auto"  />
      <Avatar placeholder={AvatarDefault} src="123" alt="hello" size="auto"   />
      <Avatar placeholder={AvatarDefault} size="auto" alt="hello" />
     </div>
    );
};

export default Page;

接口

属性类型默认值作用
Componentnodei容器组件
childrennode-子元素
classNamestring-class
srcstring-图片地址
altstring.isRequired-图片描述
sizestring | number'40'Avatar 尺寸
placeholdernode | string-图片加载失败
  • size:size={null} 表示头像会撑满整个容器
  • placeholder: string 表示图片加载失败用这个作为占位图,

更多

Keywords

react-component

FAQs

Package last updated on 18 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts