Skip to content

Icon

基础用法

html

<pa-icon name="appreciate" />

颜色大小

html

<pa-icon name="success" size="100" />
<pa-icon name="success" size="50" color="green" />
<!-- 样式形式,方便继承父级样式 -->
<pa-icon name="success" style="font-size: 50px; color: red" />

全部图标

html

<view class="grid grid-cols-4">
  <view
    v-for="(name, index) in icons"
    :key="index"
    class="flex flex-col items-center justify-center"
    style="height: 100px"
    @tap="onCopy(name)"
  >
    <pa-icon :name="name" size="50" />
    <text class="text-24">{{ name }}</text>
  </view>
</view>
ts

import { ref } from 'vue'
import iconsJSON from '../../fonts/iconfont.json'

const icons = ref<string[]>(iconsJSON.glyphs.map((item) => item.font_class))

const onCopy = (name: string) => {
  uni.setClipboardData({
    data: `<pa-icon name="${name}" />`,
    success: function () {
      uni.showToast({
        icon: 'none',
        title: '复制成功',
      })
    },
  })
}

Icon Props

参数说明类型默认值
name图标名称string-
size图标大小string-
color图标颜色CSSProperties['color']-
block是否块级元素boolean-
customClass自定义类名string-
customStyle自定义样式CSSProperties-
classPrefix类名前缀string-

Icon Event

事件名参数
click(value: Event)

Icon Slot

名称说明

样式变量

名称默认值
--pa-icon-sizeinherit