我正在尝试在React Native项目中链接自定义字体,当使用npx react-native link命令时,出现了“Unrecognized command "link"”的错误。
有没有解决这个问题的方法?
我正在尝试在React Native项目中链接自定义字体,当使用npx react-native link命令时,出现了“Unrecognized command "link"”的错误。
有没有解决这个问题的方法?
在react-native 0.69中,手动链接已被移除,取而代之的是自动链接功能,因此现在您需要在原生模块中链接您的资产,否则您可以使用react-native-asset。
其余步骤与以前相同,在项目的根目录中创建一个文件
react-native.config.js
module.exports = {
project: {
ios: {},
android: {}
},
assets: ['./src/assets/'],
};
安装完react-native-asset后,请运行以下命令。yarn react-native-asset or npx react-native-asset
手动设置图标并尝试以下步骤
1.在android/app/build.gradle中添加此行 apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
2.在android/setting.gradle中添加此行 include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android'):