我如何将这段代码注入对象值?

问题描述 投票:0回答:2

反正我可以将headstyles对象添加到headText对象吗?我很容易将headStyles对象注入headConfig

从'@ material-ui / core'导入{makeStyles}

const headStyles = {
    backgroundColor:'green',
    borderRadius:10,
    padding:7
}

// CSS Styles
const useStyles = makeStyles( theme => ({ 

box: {
    position: 'absolute',
    width:'100vw',
    display:'grid',
    textAlign:'center',
    alignItems:'center',
    marginTop:'10vh',
    color:'white'
},

avatar: {
    justifySelf:'center',
    width: theme.spacing(19),
    height: theme.spacing(19),
    margin: theme.spacing(6),
},
headText: {
    position: 'relative',
    color: '#aaa',
    zIndex:1,
    top:'10vh',
    // TRYING TO ADD (headStyles) IN HERE SOMEHOW  <<<<<<<<<<<<<<<---------
},
headConfig: headStyles
}))
javascript reactjs object material-ui key-value
2个回答
0
投票
因此,在您的示例中,您应该可以:

headText: { position: 'relative', color: '#aaa', zIndex:1, top:'10vh', ...headStyles },


0
投票
© www.soinside.com 2019 - 2024. All rights reserved.