react-native - 反应原生 - 无法在“CSSStyleDeclaration”上设置索引属性
问题描述
我想动态替换 css 变量,但得到以下错误 -
global.js
answerzerocontainer: {
flex: .5,
backgroundColor: '#fcba03',
marginBottom:10,
justifyContent: 'center',
},
测试.js
<View style={globalStyles.homepagecontainer}>
<Text>{question}</Text>
{
answers.map((a, key)=> {
key = 'zero'
const cssstyle = 'globalStyles.answer' + key + 'container'
console.log('style - ', cssstyle)
return (<View style={cssstyle}>
<Text>a</Text>
</View>)
})
}
错误 :-
Failed to set an indexed property on 'CSSStyleDeclaration'
解决方案
你能把数字值也放在一对单引号“10”内吗?
推荐阅读
- sql - 在sql中压缩行
- oracle - Oracle OS 身份验证
- python - Django 自定义装饰器 - 属性错误
- react-native - 读取加速度计数据的后台任务
- ms-access - 计算字段中的 MS ACCESS 格式数字
- java - Android Studio API 级别 23+ 中的 HTTP 获取
- shell - NewNetIPAddress:ActiveStore 与 PersistantStore
- java - 在 Spring 多租户配置期间自动装配 Jpa 存储库
- c# - 从 WCF C# 中的 SOAP 消息中使用多部分 MIME 对象
- r - ggplot疑难解答:错误:美学必须是长度1或与数据相同(24):x,y,填充