微信小程序引用iconfont

之前引入iconfont发现很麻烦
要将ttf文件转化成beast64

之后我发现了一个跟这些不同的方法
不过也有缺点
话不多说

1.需要把iconfont的源文件传到服务器

2.在css引用

@font-face {font-family: 'iconfont';
    src: url('https://**********/iconfont.eot');
    src: url('https://**********/iconfont.eot?#iefix') format('embedded-opentype'),
    url('https://**********//iconfont.woff') format('woff'),
    url('https://**********//iconfont.ttf') format('truetype'),
    url('https://**********//iconfont.svg#iconfont') format('svg');
}
icon{
  font-family:"iconfont" !important;
  font-style:normal;
  -webkit-font-smoothing: antialiased;
  -webkit-text-stroke-width: 0.2px;
  -moz-osx-font-smoothing: grayscale;
  -webkit-transition: font-size 0.25s ease-out 0s;
  -moz-transition: font-size 0.25s ease-out 0s;
  transition: font-size 0.25s ease-out 0s;
  font-size: 60rpx;
  -webkit-text-fill-color: transparent;
  background-clip: border-box;
  -webkit-background-clip: text;
}

这段代码来自iconfont里的不过小程序里引用本地路报错
改成了网路路径 就好了
之后打开下载包里的html

在这里插入图片描述
复制这个 ’ 口 ‘
在wxml里

<icon>口</icon>

这么放入就可以了
在这里插入图片描述

发布了5 篇原创文章 · 获赞 14 · 访问量 414

猜你喜欢

转载自blog.csdn.net/qhyk519/article/details/96996803