我想更改来自端点的文本颜色。它仅在 UI 上显示三元运算符的值('backgroundColor:green)。有人可以帮助我吗?
mainTrack() {
this.axios
.get(
`${configObject.apiBaseUrl}/Maintenance/Company`,
configObject.authConfig()
)
.then((res) => {
this.maintainTrack= res.data;
this.maintainTrack.forEach(element => {
element.isResolve = element.isResolve== 'true' ? 'backgroundColor:green' :
'backgroundColor:red'
});
})
.catch((error) => {});
}, Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
尝试返回样式对象而不是字符串:
element.isResolve = { backgroundColor : element.isResolve ? 'green':'red' }