无法在 react native >= 0.60 中链接资产(字体) [英] Can't link assets (fonts) in react native >= 0.60

查看:28
本文介绍了无法在 react native >= 0.60 中链接资产(字体)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

react-native: 0.60.4,
react: 16.8.6,
npm: 6.10.1
XCode: 10.2.1
AndroidStudio: 3.4.1

我使用

npx react-native init awesomeApp --template typescript

我已将我的资产放入

assets/fonts/<Bunch of .ttf files>

我的目录结构

awesomeApp
|
+--android
+--ios
+--assets
|  |
|  +---fonts
|      |
|      +-- ProximaNova-Bold.ttf
+--react-native-config.js

然后我跑了react-native 链接

什么也没发生,XCode 没有显示任何添加的资源,也没有显示 android,并且当我运行 react-native run-ios 时显示找不到字体的错误.

Nothing happends, XCode not showing any added Resource neither the android, and when I'm running react-native run-ios showing error that the font is not found.

我的react-native-config.js

module.exports = {
    project: {
        ios: {},
        android: {},
    },
    assets: ['./assets/fonts']
};

我也试过yarn react-native linknpx react-native link

推荐答案

嗯,最后,我链接了我的字体,

Well, finally, I linked my fonts,

我刚刚将我的文件 react-native-config.js 重命名为 react-native.config.js 并且它起作用了.

I just renamed my file react-native-config.js to react-native.config.js and it worked.

我不知道这是否是正确的方法,我只是尝试过,它奏效了,至少对我来说是这样.

I don't know if this is the right way, I just tried and it worked, for me at least.

这是链接自定义字体的完整演练.

这篇关于无法在 react native >= 0.60 中链接资产(字体)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆