Layout 레이아웃
Layout은 화면을 빠르게 배치하기 위한 그리드 컴포넌트예요. Row와 Col 두 컴포넌트가 한 세트예요.
출처: 문서
설치
@nutui/nutui에서 컴포넌트 두 개를 모두 가져와 앱에 등록하세요.
import { createApp } from 'vue'
import { Row, Col } from '@nutui/nutui'
const app = createApp()
app.use(Row)
app.use(Col)
사용 예시
기본 사용법
Layout 컴포넌트는 24칸 그리드를 제공해요. Col에 span 속성을 더해 컬럼 너비의 비율을 정하고, offset 속성으로 컬럼의 오프셋 너비를 정할 수 있어요. 계산 방법은 span과 같아요.
demo: layout basic
컬럼 간격
demo: layout gap
Flex 레이아웃
demo: layout flex
API
Row Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| type | layout method, optional value is flex |
string | - |
| gutter | spacing between column elements (px) |
string | number | - |
| justify | Flex main axis alignment, optional values are start end center space-around space-between space-evenly |
string | start |
| align | Flex cross axis alignment, optional values are flex-start center flex-end |
string | flex-start |
| flex-wrap | Whether flex wraps, optional values are nowrap wrap reverse |
string | nowrap |
Col Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| span | column element width (divided into 24 parts in total, for example, if there are 3 in a row, then the span value is 8) | string | number | 24 |
| offset | column element offset distance | string | number | 0 |
Row Events
| Event | Description | callback parameter |
|---|---|---|
| click | Triggered when clicked | event: MouseEvent |
Col Events
| Event | Description | callback parameter |
|---|---|---|
| click | Triggered when clicked | event: MouseEvent |
Types v4.3.2
이 컴포넌트는 아래 타입 정의를 함께 내보내요.
import type {
RowProps,
RowInstance,
ColProps,
ColInstance
} from '@nutui/nutui';
더 알아보기 (Learn more)
- 원문 문서: NutUI Layout 공식 문서(영문)
- NutUI는 JD.com이 공개한 Vue 3 모바일 컴포넌트 라이브러리예요. 전체 컴포넌트 목록은 공식 문서 사이트에서, 소스 코드는 GitHub 저장소에서 볼 수 있어요.