我环顾四周,到目前为止,似乎对属性键的唯一约束是避免使用空格(中间)和=(显然)键,即a.property.key = value
我想知道是否还有其他限制(或java内置方法),因为我想接受任何给定的字符串并能够进行规范化,因此它就像属性键一样工作,例如:
给定字符串: onRefresh = async () => {
const { data } = this.props
try {
this.setState({ refreshing: true })
await data.refetch({ page: 1 })
} catch (e) {
// todo
} finally {
this.setState({
refreshing: false,
})
}
}
const NudgeList = ({
nudges,
loading,
refreshing,
onRefresh,
}) => {
let inner
if (loading && !refreshing && !fetchingMore) {
inner = (
<View style={styles.center}>
<ActivityIndicator animating />
</View>
)
} else {
inner = (
<FlatList
onRefresh={onRefresh}
refreshing={refreshing || false}
scrollEventThrottle={400}
data={nudges}
renderItem={({ item }) => (
<NudgeCard nudge={item} {...{ onOpenNudge }} />
)}
/>
)
}
return (
<View style={styles.container}>
{inner}
</View>
)
}
属性键:This & this _5 will be used as a prop-key
答案 0 :(得分:1)
没有限制,只使用转义字符:
This\ &\ this\=\ _5=prop value
然后在java:
properties.getProperty("This & this= _5");// retrurs "prop value"