【发布时间】:2021-01-08 06:57:46
【问题描述】:
我在 react-native 应用程序中有以下功能组件。在第二行代码中,...attributes 令人困惑。虽然我知道它代表较新 JavaScript 版本中的扩展语法,但我找不到 attributes 的含义。如果它说..props,那是可以理解的。我尝试谷歌但找不到任何合适的答案。
问题
下面第二行代码sn-p中的attrributes是什么意思?
const Loader = (props) => {
const { loading, loaderColor, loaderText, ...attributes } = props;
return (
<Modal
transparent={true}
animationType={'none'}
visible={loading}
onRequestClose={() => {
console.log('close modal');
}}>
<View style={styles.modalBackground}>
<View style={styles.activityIndicatorWrapper}>
<ActivityIndicator
animating={loading}
color={loaderColor? loaderColor : '#0000ff'}
size={Platform.OS === 'ios' ? 'large' : 75}
/>
{loaderText ? (
<View style={{ flexDirection: 'row' }}>
<Text style={styles.modalText}>{loaderText}</Text>
</View>
) : (
''
)}
</View>
</View>
</Modal>
);
};
【问题讨论】:
-
代码从哪里来??
-
这是我在 react native 应用中看到的一个组件。
标签: javascript react-native spread-syntax