uni-app 简单引入iconfont示例(阿里妈妈)

一、首先打开iconfont(阿里妈妈)网址:iconfont 阿里妈妈

在这里插入图片描述找到自己需要的图标,添加到购物车
在这里插入图片描述
点击左上角购物车,添加至项目
在这里插入图片描述
然后进入项目中,导出
在这里插入图片描述
在这里插入图片描述

二、解压文件后,仅取

iconfont.css
iconfont.woff
放到 static/css 中
在这里插入图片描述

注意:两个注意点

  1. 如果项目中采用了 自动化cli的打包及上传微信小程序,必须删除多余文件,保留上述两个文件,不然容易报如下错误。
MiniProgramError
TypeError: Cannot set properties of undefined (setting '_iconfont_svg_string_3883524')
Error: TypeError: Cannot set properties of undefined (setting '_iconfont_svg_string_3883524')
TypeError: Cannot set properties of undefined (setting '_iconfont_svg_string_3883524')
at (app-service.js:1290:36)
at I (WASubContext.js:1:810950)
at (app-service.js:1291:10)
  1. iconfont中 url地址需更改为绝对地址 即 url(‘~@/static/css/iconfont.woff?t=1675740316787’) format(‘woff’)
@font-face {
  font-family: "iconfont"; /* Project id 3883524 */
  src: url('~@/static/css/iconfont.woff?t=1675740316787') format('woff')
}

.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-saomiao:before {
  content: "\e622";
}

三、在app.vue中引入iconfont.css

在这里插入图片描述

<style>
@import "@/static/css/iconfont.css";
	/*每个页面公共css */
</style>

四、在vue文件中使用

在这里插入图片描述

	<view class="iconfont icon-saomiao"></view>
	<view style="margin-left: 5rpx;">解码</view>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值