Bri*_* H. 5 reactjs react-native react-native-vector-icons
我用于react-native-vector-icons我的 React 本机项目。最近,当我打开我的应用程序时,它不断显示我在字段中填写的错误图标name,或者显示该图标不存在(“问号”)。
我感觉很尴尬,因为大约一两周后就正常了。我一直在 SOF 或他们的 github 上搜索,但感觉没有希望。
你能帮我解决这个问题吗?
<Icon
containerStyle={{
display: (this.state.email.length > 0) ? 'flex' : 'none',
marginRight: normalize(10),
}}
name="mail-outline"
type="ionicon"
color="#7384B4"
size={22}
onPress={() => {
this.setState({ email: '' });
}}
/>Run Code Online (Sandbox Code Playgroud)
这是我在我的项目中使用过的一些相关依赖版本package.json
"react": "16.9.0",
"react-native": "0.61.3",
"react-native-elements": "^1.2.0",
"react-native-vector-icons": "^7.0.0",
Run Code Online (Sandbox Code Playgroud)
谢谢,祝你有美好的一天。
您应该import Icon以具体方式声明,
例子:import Icon from 'react-native-vector-icons/Ionicons'
例如:
import Icon from 'react-native-vector-icons/Ionicons'
//or you can use
//import Ionicons from 'react-native-vector-icons/Ionicons'
//usage
<Icon
//containerStyle={{
//display: (this.state.email.length > 0) ? 'flex' : 'none',
//marginRight: normalize(10),
//}}
//i think it should be `style` not `containerStyle`
//except you are using another lib to show icon
style={{
display: (this.state.email.length > 0) ? 'flex' : 'none',
marginRight: normalize(10),
}}
name="mail-outline"
color="#7384B4"
size={22}
onPress={() => {
this.setState({ email: '' });
}}
/>
//another way
//<Ionicons
//{...all props you need to define}
///>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3561 次 |
| 最近记录: |