本机基本复选框显示连字符而不是勾号
Native base checkbox shows hyphen instead of tick
我将 Native Base 与 React Navigation 5 结合使用,Native Base 的复选框显示连字符 (-) 而不是勾号。此外,内容不显示文本。
/**
* @format
*/
import React from 'react';
import 'react-native-gesture-handler';
import { AppRegistry } from 'react-native';
// import NavigationInitializer from './route/NavigationSetup';
import { name as appName } from './app.json';
import { LogBox } from 'react-native';
import { Root, Container, CheckBox, Content, Header, Text, Footer, Body } from 'native-base';
LogBox.ignoreAllLogs(); // remove unnecessary warnings
// This is useful when there's a noisy warning that cannot be fixed, like those in a third-party dependency.
// AppRegistry.registerComponent(appName, () => NavigationInitializer);
AppRegistry.registerComponent(appName, () => () =>
<Container>
<Header>
<Body>
<Text style={{ color: "#fff" }}>
Checkbox
</Text>
<CheckBox checked={true} />
</Body>
</Header>
<Content style={{ backgroundColor: "purple" }}>
<Text style={{ color: "black" }}>
This is Content Section
</Text>
</Content>
<Footer>
<Text style={{ color: "black" }}>
This is Footer Section
</Text>
</Footer>
</Container>
);
您需要做两件事。第一,确保安装 react-native-vector-icons。第二,您需要将字体添加到 /android/app/build.gradle 文件中。下面一行就足够了。
//字体
申请自:“../../node_modules/react-native-vector-icons/fonts.gradle”
此行加载 react-native-vector-icons 套件中的所有字体。
最后,我手动修复了它 linking:
react-native link react-native-矢量图标
正如这里所讨论的:
1- 编辑 android/app/build.gradle 并添加以下内容:
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle";
2- 编辑 android/settings.gradle 看起来像这样(没有 +):
rootProject.name = 'MyApp'
include ':app'
+ include ':react-native-vector-icons'
+ project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
3- 编辑 android/app/build.gradle(注意:app 文件夹)如下所示:
apply plugin: 'com.android.application'
android {
...
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
+ compile project(':react-native-vector-icons')
}
4- 将所有字体从 ../node_modules/react-native-vector-icons/Fonts 复制到 ../android/app/src/main/assets/fonts
我将 Native Base 与 React Navigation 5 结合使用,Native Base 的复选框显示连字符 (-) 而不是勾号。此外,内容不显示文本。
/**
* @format
*/
import React from 'react';
import 'react-native-gesture-handler';
import { AppRegistry } from 'react-native';
// import NavigationInitializer from './route/NavigationSetup';
import { name as appName } from './app.json';
import { LogBox } from 'react-native';
import { Root, Container, CheckBox, Content, Header, Text, Footer, Body } from 'native-base';
LogBox.ignoreAllLogs(); // remove unnecessary warnings
// This is useful when there's a noisy warning that cannot be fixed, like those in a third-party dependency.
// AppRegistry.registerComponent(appName, () => NavigationInitializer);
AppRegistry.registerComponent(appName, () => () =>
<Container>
<Header>
<Body>
<Text style={{ color: "#fff" }}>
Checkbox
</Text>
<CheckBox checked={true} />
</Body>
</Header>
<Content style={{ backgroundColor: "purple" }}>
<Text style={{ color: "black" }}>
This is Content Section
</Text>
</Content>
<Footer>
<Text style={{ color: "black" }}>
This is Footer Section
</Text>
</Footer>
</Container>
);
您需要做两件事。第一,确保安装 react-native-vector-icons。第二,您需要将字体添加到 /android/app/build.gradle 文件中。下面一行就足够了。
//字体 申请自:“../../node_modules/react-native-vector-icons/fonts.gradle”
此行加载 react-native-vector-icons 套件中的所有字体。
最后,我手动修复了它 linking:
react-native link react-native-矢量图标
正如这里所讨论的:
1- 编辑 android/app/build.gradle 并添加以下内容:
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle";
2- 编辑 android/settings.gradle 看起来像这样(没有 +):
rootProject.name = 'MyApp'
include ':app'
+ include ':react-native-vector-icons'
+ project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
3- 编辑 android/app/build.gradle(注意:app 文件夹)如下所示:
apply plugin: 'com.android.application'
android {
...
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
+ compile project(':react-native-vector-icons')
}
4- 将所有字体从 ../node_modules/react-native-vector-icons/Fonts 复制到 ../android/app/src/main/assets/fonts