uniApp之在伪类中使用iconfont

效果如下:

 THML:

<view class="process">
    <view class="ht">处理进度</view>
    <view class="processList">
        <view v-for="(list,index) in arrivalProcess" :key="index">
            <text>{{list.content}}</text>
            <text>{{list.time}}</text>
        </view>
    </view>
</view>

CSS:

/*引入iconfont*/
@import url("//at.alicdn.com/t/font_xxxxxx.css");
.process{padding:2rem 0 0 0;box-shadow:0 0 0.5rem #fdd3c6;background:#fff;border-radius:1rem;}
.processList{padding-left:3rem;margin:2rem 1rem 0 1rem;position:relative;}
.processList:before{content:"";display:block;position:absolute;left:1rem;top:0;width:0.1rem;height:82%;background:#ff7832;}
.processList >view{display:flex;justify-content:space-between;position:relative;padding-bottom:2rem;}
.processList >view text:last-child{color:#969696;font-size:1.3rem;}
.processList >view:before{font-family:"iconfont";display:block;position:absolute;left:-2.8rem;top:-0.2rem;font-size:2rem;color:#ff7832;background:#fff;}
.processList >view:nth-child(1):before{content:"\e60b"}
.processList >view:nth-child(2):before{content:"\e6d9"}
.processList >view:nth-child(3):before{content:"\e610"}

数据Data:

arrivalProcess:[
    {content:"申请已提交",time:"2021-06-30  15:40"},
    {content:"处理中...",time:"2021-06-30  15:40"},
    {content:"微信到账成功",time:"2021-06-30  15:40"}
]

划重点:

1、iconfont码要转译

 2、要加字体 font-family:"iconfont"

### 如何在 UniApp 微信小程序项目中集成和使用 IconFont 图标 #### 准备工作 为了能够在 UniApp 开发的小程序内成功加载并显示来自 IconFont图标,需先完成准备工作。访问 IconFont 官网挑选所需图标,并将其加入购物车后创建专属项目[^1]。 #### 文件处理与放置 下载所选图标的压缩包解压后,将其中的 `iconfont.css` 和 `.ttf` 字体文件置于项目的 `common` 或者静态资源目录下以便后续引用[^2]。 #### CSS 引入方式调整 对于已获取到手的 `iconfont.css` 文件,考虑到部分设备可能存在兼容性问题导致图标未能正常展示,建议通过在线工具(例如 Transfoner 提供的服务)把该样式表转化为 Base64 编码形式再行引入,从而规避潜在障碍[^3]。 #### 应用层面上的具体操作 确保上述步骤完成后,在应用入口文件 `App.vue` 中全局注册字体图标: ```javascript // App.vue <style> @import url('/static/common/iconfont.css'); /* 假设放在 static 下 */ </style> ``` 随后便可以在各个组件内部按照既定规则调用这些图标了。比如下面这段代码片段展示了如何在一个视图容器 `<view>` 内嵌套三个不同型的图标实例: ```html <template> <view> <!-- 使用时只需指定对应的名即可 --> <view class="iconfont icon-24gl-checklist"></view> <view class="iconfont icon-others"></view> <view class="iconfont icon-unorderedlist"></view> </view> </template> <!-- 如果需要改变颜色,则可以通过额外添加CSS样式实现 --> <style scoped> .icon-24gl-checklist { color: red; } </style> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值