1.0.13 • Published 2 months ago

@tanzhenxing/zx-title v1.0.13

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

zx-title 标题组件

介绍

zx-title 是一个用于显示标题的组件,支持多种标题级别、副标题、图标和右侧操作区域,适用于各种标题展示场景。

基本用法

<zx-title title="标题文本" type="h2"></zx-title>

带图标

<zx-title title="带图标的标题" iconShow icon="home" iconColor="#3c9cff"></zx-title>

带副标题

<zx-title title="主标题" subtitle="副标题描述" type="h2"></zx-title>

带右侧操作

<zx-title title="带操作的标题" rightText="更多" @right="handleRight"></zx-title>

自定义右侧内容

<zx-title title="自定义右侧">
  <template #right>
    <button size="mini" type="primary">操作按钮</button>
  </template>
</zx-title>

自定义样式

<zx-title 
  title="自定义样式" 
  type="h3" 
  color="#ff5500" 
  background="#f8f8f8" 
  padding="20rpx" 
  borderRadius="10rpx">
</zx-title>

API

属性

属性名类型默认值说明
typeStringh2标题级别,可选值:h1、h2、h3、h4、h5
titleString-标题内容
subtitleString-副标题内容
alignStringleft对齐方式,可选值:left、center、right
colorString#333333标题文字颜色
subtitleColorString#666666副标题文字颜色
boldBooleantrue是否加粗
iconString-图标名称
iconShowBooleanfalse是否显示图标
iconColorString#3c9cff图标颜色
iconSizeString40rpx图标大小
iconWidthString-图标容器宽度
rightTextString-右侧文本
rightTextColorString#3c9cff右侧文本颜色
rightTextSizeString28rpx右侧文本大小
marginString0外边距
paddingString15rpx 0内边距
backgroundStringtransparent背景颜色
borderRadiusString0圆角大小

事件

事件名说明回调参数
right点击右侧文本时触发-

插槽

名称说明
right自定义右侧内容

示例代码

<template>
  <view>
    <!-- 基础用法 -->
    <zx-title title="基础标题" type="h2"></zx-title>
    
    <!-- 带图标 -->
    <zx-title 
      title="带图标的标题" 
      iconShow 
      icon="star" 
      iconColor="#ff9900">
    </zx-title>
    
    <!-- 带副标题 -->
    <zx-title 
      title="产品详情" 
      subtitle="了解更多产品信息和使用方法" 
      type="h3" 
      color="#2979ff">
    </zx-title>
    
    <!-- 带右侧文本 -->
    <zx-title 
      title="消息列表" 
      rightText="查看全部" 
      @right="onViewAll">
    </zx-title>
    
    <!-- 自定义右侧内容 -->
    <zx-title title="商品分类">
      <template #right>
        <view class="custom-right">
          <button size="mini" type="primary">筛选</button>
        </view>
      </template>
    </zx-title>
    
    <!-- 自定义样式 -->
    <zx-title 
      title="热门推荐" 
      background="#f5f5f5" 
      padding="20rpx 30rpx" 
      borderRadius="10rpx" 
      iconShow 
      icon="fire" 
      iconColor="#ff5500">
    </zx-title>
  </view>
</template>

<script setup>
const onViewAll = () => {
  uni.navigateTo({
    url: '/pages/message/list'
  });
};
</script>
1.0.1

3 months ago

1.0.11

3 months ago

1.0.13

2 months ago

1.0.12

2 months ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.0

1 year ago