小编CLO*_*UGH的帖子

从样式表反应本机访问状态

我正在尝试根据状态设置容器的背景,但它不断向我显示未定义错误bg

constructor(props) {
    super(props)
    this.state = {
        bg:'#fff'
    }
}

render(){
    return(<View style={styles.container} />)
} 

const styles = StyleSheet.create({
    container:{
        flex: 1,
        backgroundColor: this.state.bg,
    }
})
Run Code Online (Sandbox Code Playgroud)

react-native

3
推荐指数
1
解决办法
3044
查看次数

标签 统计

react-native ×1