【发布时间】:2021-09-22 14:36:59
【问题描述】:
我有我的Welcome.tsx 文件:
import React from 'react';
import {View, StyleSheet, Text, Button, TouchableOpacity} from 'react-native';
import Icon from 'react-native-vector-icons/Feather';
const WelcomeScreen: React.FC<{}> = () => {
return (
<View style={styles.container}>
<View style={styles.logo}>
<Icon size={150} color="black" name="book-open" />
<Text style={styles.logoText}>Book Worm</Text>
</View>
<View style={styles.divider}>
<TouchableOpacity>
<Button title="Login" color="black" style={styles.btn} />
</TouchableOpacity>
<TouchableOpacity>
<Button title="Sign-up" color="black" style={styles.btn} />
</TouchableOpacity>
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
logo: {
flex: 1,
borderWidth: 1,
alignItems: 'center',
justifyContent: 'center',
},
logoText: {
fontSize: 50,
fontWeight: '100',
},
divider: {
flex: 1,
borderWidth: 1,
},
btn: {
borderWidth: 1,
borderColor: 'black',
backgroundColor: 'black',
},
});
export default WelcomeScreen;
如您所见,这很正常。但是,Visual Studio 代码突出显示 style 属性并引发以下错误:
No overload matches this call.
Overload 1 of 2, '(props: ButtonProps | Readonly<ButtonProps>): Button', gave the following error.
Type '{ title: string; color: string; style: { borderWidth: number; borderColor: string; backgroundColor: string; }; }' is not assignable to type 'IntrinsicAttributes &
图片如下:
知道是什么导致了这个重载匹配调用吗?想知道这件事发生了几次。
【问题讨论】:
标签: javascript typescript react-native