본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

AvatarCropper 아바타 크롭

원문 보기 위키 갱신

AvatarCropper는 프로필 사진을 잘라서 새 이미지를 만들 때 쓰는 컴포넌트예요. NutUI 4.2.0 이상에서 쓸 수 있어요.

출처: 문서

설치

@nutui/nutui에서 컴포넌트를 가져와 앱에 등록하면 바로 쓸 수 있어요.

import { createApp } from 'vue'
import { AvatarCropper } from '@nutui/nutui'

const app = createApp()
app.use(AvatarCropper)

사용 예시

기본 사용법

가운데에 아바타 컴포넌트를 바로 두면, 크롭이 끝난 뒤 이미지 내용이 새 이미지로 교체돼요.

demo: avatarcropper basic

모양 v4.2.8

모양은 square, round 중에서 고를 수 있어요.

demo: avatarcropper shape

크롭 영역 툴바 슬롯

크롭 영역의 툴바를 커스터마이즈해요. toolbar-position으로 툴바 위치를 정할 수 있어요.

demo: avatarcropper toolbar

API

AvatarCropper Props

Attribute Description Type Default
max-zoom Maximum zoom number 3
space The gap reserved on both sides of the clipping area number 20
toolbar-position Location of the toolbar in the clipping area. The optional value is:top bottom string bottom
edit-text The text content in the middle string 编辑
cancel-text Cancel button text string 取消
cancel-confirm Confirm button text string 确认
shapev4.2.8 Shape of avatar. The optional value is: square、round string square

AvatarCropper Slots

Name Description
default The default slot for placing elements such as images, ICONS, and text
toolbar After selecting the file, crop the bottom element of the pop-up window can be customized, and invoke the method of the component through ref

AvatarCropper Events

Name Description Callback Arguments
confirm Click Confirm to trigger after cropping url:The trimmed base64
cancel Click cancel trigger -

AvatarCropper Ref

Event Explain
cancel uncrop
reset Reset to 0 degrees
rotate Rotate 90 degrees
confirm Definite cut

더 알아보기 (Learn more)