【问题标题】:Native base checkbox shows hyphen instead of tick本机基础复选框显示连字符而不是勾号
【发布时间】:2020-08-01 08:04:33
【问题描述】:

我正在使用带有 React Navigation 5 的 Native Base,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 react-navigation native-base


    【解决方案1】:

    您需要做两件事。一,确保安装 react-native-vector-icons。二,您需要将您的字体添加到 /android/app/build.gradle 文件中。以下行就足够了。

    //字体 申请自:“../../node_modules/react-native-vector-icons/fonts.gradle”

    这一行会加载你在 react-native-vector-icons 套件中的所有字体。

    【讨论】:

    • 我更新了 gradle 文件。适用于:“../../node_modules/react-native-vector-icons/fonts.gradle”另外,我在文件夹视图的该路径中找不到文件 fonts.gradle。
    【解决方案2】:

    最后,我通过手动链接修复了它:

    react-native 链接 react-native-vector-icons

    正如这里所讨论的:

    https://github.com/GeekyAnts/NativeBase/issues/2855

    【讨论】:

      【解决方案3】:

      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

      【讨论】:

        猜你喜欢
        • 2018-04-23
        • 2013-07-04
        • 2013-09-14
        • 2011-02-04
        • 1970-01-01
        • 2021-12-07
        • 2022-09-23
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多