8

使用下面的小吃: https ://snack.expo.io/ry_5rCk84

我正在尝试在我的 react native 应用程序中使用 Material Icons 显示图标“wifi_off”(只是在博览会上将其作为零食分享,以便于分享),但这不是道具“名称”的公认价值。最后显示一个“?” 对于未知的图标。我可以使用 ' material-community ' 图标集来使用wifi-off图标

import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { Constants } from 'expo';
import {Icon} from 'react-native-elements';

// You can import from local files
import AssetExample from './components/AssetExample';

// or any pure javascript modules available in npm
import { Card } from 'react-native-paper';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.paragraph}>
          Change code in the editor and watch it change on your phone! Save to get a shareable url.
        </Text>
        <Card>
          <AssetExample />
        </Card>
        <Icon name='wifi' size={50} type='material'/>
        <Icon name='wifi-off' size={50} type='material-community' />
        <Icon name='wifi_off' size={50} type='material' />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  paragraph: {
    margin: 24,
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
  },
});

在此处输入图像描述

4

2 回答 2

9

react-native-elements用于react-native-vector-icons显示图标。

react-native-vector-icons有一个目录,您可以在其中检查哪些图标可用,您可以按名称查找它们。https://oblador.github.io/react-native-vector-icons/

如果您搜索名称中包含wifi的所有图标,您会发现MaterialIconsMaterialCommunityIcons的以下结果

可用的图标

如果你搜索wifi_off你会发现没有结果。

在此处输入图像描述

因此wifi_off无法使用。

还值得注意的是,react-native-elements目前不支持最新版本react-native-vector-icons,你可以在这个当前打开的issue中看到。

于 2019-02-24T09:12:28.073 回答
1

当您使用反应原生元素图标时,它在幕后搜索列表https://github.com/oblador/react-native-vector-icons/blob/master/glyphmaps/MaterialIcons.json,在这里您可以找到支持的图标名称,如您所见,“wifi_off”不在这里,也许您可​​以尝试“signal-wifi-off”。

于 2019-02-24T09:13:27.407 回答