Comments (10)
@jlsky
Weex如何在native中加载本地的字体文件,如iconfont - 个人文章 - SegmentFault
from incubator-weex-ui.
这是我的使用方法,仅供参考:
定义css
* {
font-family: "iconfont" !important;
}
加载字体
beforeCreate() {
var domModule = weex.requireModule('dom');
//目前支持ttf、woff文件,不支持svg、eot类型,moreItem at http://www.iconfont.cn/
domModule.addRule('fontFace', {
'fontFamily': "iconfont",
'src': "url('//at.alicdn.com/t/font_153151_5zv8k123shziwwmi.ttf')"
});
}
然后就可以愉快的使用了:
<text>用户中心</text>
from incubator-weex-ui.
@play175 我们这也采用类似方案,封装了一个组件来处理图标的问题。目前类似wxc-tab-page组件中的图标是图片,如果使用图标需要自行修改才可以。如果在组件中可以直接支持字体图标,用起来会更方便。
from incubator-weex-ui.
@hizhengfu 我对wxc-tab-page 进行了一次升级,新增自定义nav栏头部 这样就可以使用iconfont了
同时还有一些其他的升级,可以看一下wxc-tab-page的文档哦
from incubator-weex-ui.
问一下,把字体放在android的assets里可以吗?试验了两天,没出来。之间,只要把链接改为网络,就没问题。
domModule.addRule 支不支持从本地读取字体?
from incubator-weex-ui.
@jlsky 本地可能是路径问题 获取不到的 建议放到cdn 或者直接使用http://iconfont.cn/
from incubator-weex-ui.
真是奇怪了。刚把问题发上来,就发现,字体显示了。
我把字体放在了app的assets目录下。
mydom.addRule('fontFace', {
'fontFamily': "iconfont3",
'src': "url('file://asstes/iconfont2.ttf')"
});
另外说明,用weex playground源码里的android代码,在加载本地js代码时,bundelUrl指向的是 http://your_ip:12580/examples/build/ 而不是js代码所在的assets目录。
from incubator-weex-ui.
重新说明一下,字体在本地还是不成功。此前说的,出来的原因是:我在子组件里引用了网上的字体,主界面上显示了所用的字体,误导了。
from incubator-weex-ui.
weex iconfont 字体可能第一次出不来 ,可以参考这个优化 https://segmentfault.com/q/1010000009357817
from incubator-weex-ui.
可以更新weex-ui到最新,目前wxc-tab-bar、wxc-tab-page 已经支持配置iconfont
npm i weex-ui@latest -S
from incubator-weex-ui.
Related Issues (20)
- weexCell assembly slot value nesting input Invalid HOT 1
- [BUG]Weex Playground无法扫描README中的二维码 HOT 1
- wxc-ep-slider 没有滑动事件的回调吗?? HOT 1
- wxc-tab-bar iphoneX系列兼容问题 HOT 1
- 开发多语言的app,weex ui支持国际化么? HOT 1
- android下loading动画无效 HOT 1
- slider nav why not use bindingX
- one of images in example returns 404
- wxc-lightbox prop show-indicator didn't work HOT 2
- wxc-loading该组件没有api更换URL,能否进行优化一下? HOT 1
- wxc-lightbox prop show-indicator didn't work HOT 1
- wxc-searchbar的bar-style要怎么设置 HOT 1
- 引入uniapp内的nvue出现页面超级大 HOT 1
- Can't find variable: env HOT 1
- web端渲染时提示TypeError: _vm._px2rem is not a function 但是native端可以正常渲染 HOT 2
- el-slider component add infinite loop HOT 1
- wxc-ep-slider 禁用滑动 HOT 1
- 如何将项目转化为微信小程序项目呢? HOT 1
- 如何修改组件样式 HOT 1
- REQUEST: Navigation Drawer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from incubator-weex-ui.