我有一个包含2个类的javascript文件。对于这两个类,我都有单独的StyleSheets。如下图所示:
export class PageOne extends Component {
render(){
return(
<View style={pageOne.container}>
...
</View>
)
}
const pageOne = StyleSheet.create({
container: {
backgroundColor: '#FFDD33',
flex: 1,
width: '100%',
flexDirection: 'row',
},
...
});
export class PageTwo extends Component {
render(){
return(
<View style={pageTwo.container}>
...
</View>
)
}
const pageTwo = StyleSheet.create({
container: {
*Error ^*
backgroundColor: '#FFFFFF',
flex: 1,
width: '100%',
},
...
});
答案 0 :(得分:1)
我认为您错过了}
关闭您的PageOne和PageTwo类组件的情况。
尝试一下:
export class PageOne extends Component {
render() {
return(
<View style={pageOne.container}>
...
</View>
);
}
}
const pageOne = StyleSheet.create({
container: {
backgroundColor: '#FFDD33',
flex: 1,
width: '100%',
flexDirection: 'row',
},
...
});
export class PageTwo extends Component {
render(){
return(
<View style={pageTwo.container}>
...
</View>
)
}
}
const pageTwo = StyleSheet.create({
container: {
*Error ^*
backgroundColor: '#FFFFFF',
flex: 1,
width: '100%',
},
...
});