react-native - 从重构反应原生样式中得到奇怪的错误
问题描述
我遇到了一个奇怪的错误,仅仅通过将样式从内联复制和粘贴到 StyleSheet.create 方法来清理内容,这没有任何意义。它说“bottomBorderStyle”不是有效的样式属性。它在内联时起作用,所以这没有任何意义。如果我使用内联样式但还保留 StyleSheet,错误甚至仍然存在,然后如果我删除 StyleSheet,错误就会消失。
我已经尝试了我能想到的一切,以确保我没有对语法做任何愚蠢的事情,因为我对本机反应非常陌生,而且我只是想不出这个错误有意义的方法。当然,我可以保留有效的内联样式,但我真的很想了解为什么会发生这种情况以及我可能做错了什么。我在下面显示的点之间遗漏了一些代码。如果它是相关的,我可以发布其余的。更新:如果我从边框属性中删除“底部”部分,错误也会消失。
render() {
return(
<View style={{alignItems: 'center'}}>
<View style={{
backgroundColor: 'white',
borderBottomWidth: 1,
borderBottomStyle: 'dashed',
borderBottomRadius: 10,
width: '90%',
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'flex-start'
}}>
</View>
);
}
}
//Error goes away if I delete from here down
const styles = StyleSheet.create( {
FlexContainer: {
backgroundColor: 'white',
borderBottomWidth: 1,
borderBottomStyle: 'dashed',
borderBottomRadius: 10,
width: '90%',
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'flex-start'
},
});
解决方案
使用样式如下
<View style={styles.FlexContainer}></View>
推荐阅读
- java - 数据模型设计和许可
- c++ - Rcpp - 如何在 C++ 中使用 R 包中的源代码?
- sublimetext3 - Sublime Text 3 - 一劳永逸地修复标签
- javascript - svg路径上的jQuery鼠标悬停事件
- angular - 使用 openFromComponent 从 matSnackBar 获取数据
- python - 类型错误:不支持 divmod() 的操作数类型:“NoneType”和“Int”
- java - 在 grails 中生成与原始域类具有相同字段的新域类
- castle-dynamicproxy - 静态方法可以用 Castle DynamicProxy 拦截吗?
- java - 使用 Android Studio 3.0.1 为 QR 码扫描仪添加保存选项
- android - 如何在 Firebase 中对节点的子值实施唯一约束?