首页 > 解决方案 > 如何修复 react-native-barcode-builder 条形码空白

问题描述

我的 react-native 条码只显示黑色全黑条。

我已经做好了npm install react-native-svg --save && react-native link react-native-svg

下面是我的代码

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';

import Barcode from 'react-native-barcode-builder';

export default class Example extends Component {
  render() {
    return (
      <View>
        <Text>
          React Native Barcode Builder
        </Text>
        <Barcode value="Hello World" />
      </View>
    );
  }
}

我希望我能得到普通的条形码而不是全黑

标签: react-nativebarcode

解决方案


将背景颜色设置为白色,如下所示:

<Barcode value="Hello World" background="#ffffff" format="CODE128" />

推荐阅读