Skip to content

Text 텍스트 ​

제목 / 본문 / 말줄임 / 복사를 한 곳에 담은 조판 컴포넌트입니다. 의미 수식은 모두 BEM 수식 클래스로 적용됩니다.

레벨 ​

vue
<template>
  <lh-text level="h1">제목 1</lh-text>
  <lh-text level="p">본문 단락</lh-text>
  <lh-text level="caption">보조 설명</lh-text>
</template>

level은 h1 ~ h6 / p(기본) / caption을 지원합니다. 잘못된 값은 p로 대체됩니다.

의미와 수식 ​

vue
<template>
  <lh-text type="success" strong>성공·굵게</lh-text>
  <lh-text mark>강조 표시</lh-text>
  <lh-text code>코드 스타일</lh-text>
</template>

type: default(기본) / secondary / success / warning / danger. 수식 속성: strong / italic / underline / mark / code / disabled.

말줄임 ​

vue
<template>
  <lh-text :ellipsis="true">한 줄 말줄임</lh-text>
  <lh-text :ellipsis="2">두 줄 말줄임</lh-text>
</template>

ellipsis에 true를 전달하면 한 줄 말줄임, 숫자를 전달하면 줄 수로 잘라냅니다(상한 10, 여러 줄 말줄임은 인라인 -webkit-line-clamp 사용).

복사 ​

vue
<template>
  <lh-text copyable copy-text="고정 텍스트">뒤의 버튼을 눌러 복사</lh-text>
</template>

copyable은 복사 버튼을 추가합니다. 클릭 시 클립보드에 쓰고 잠시 동안「복사됨」으로 전환되며, 동시에 copy 이벤트를 발생시킵니다(인수는 실제로 쓰인 텍스트).

미니프로그램에서의 복사

H5는 copy-text를 전달하지 않으면 슬롯의 텍스트를 자동으로 가져옵니다. 미니프로그램에서는 컴포넌트가 슬롯의 텍스트를 읽을 수 없어 copy-text를 반드시 전달해야 합니다. 그렇지 않으면 버튼이 아무것도 쓰지 않습니다(클릭 자체는 copy 이벤트를 발생시킵니다). 라벨은 언어 팩 text.copy / text.copied에서 가져오며 copy-label로 덮어쓸 수 있습니다.

Props ​

속성설명타입기본값
level제목 레벨과 단락 형태'h1' | ... | 'h6' | 'p' | 'caption''p'
type의미 색상'default' | 'secondary' | 'success' | 'warning' | 'danger''default'
strong / italic / underline / mark / code / disabled불리언 수식booleanfalse
ellipsis말줄임: true는 한 줄, 숫자는 줄 수boolean | numberfalse
copyable복사 버튼 추가booleanfalse
copyLabel복사 버튼의 접근성 이름string—
copyText복사할 텍스트(미니프로그램에서 필수)string—
customClass커스텀 클래스명string—
sx빠른 레이아웃 속성LhSxProps—

Events ​

이벤트설명콜백 매개변수
copy복사 버튼 클릭(text: string)

플랫폼 차이 ​

기능H5미니프로그램
렌더링 요소view(조판은 lh-text--<level> 클래스가 담당)H5와 동일
복사copy-text 미전달 시 슬롯 텍스트 자동 사용(navigator.clipboard)copy-text 필수, uni.setClipboardData 사용(시스템 알림 있음)