我想更改来自端点的文本颜色。它仅在 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) => {}); },
P粉4818158972024-03-20 18:14:53
尝试返回样式对象而不是字符串:
element.isResolve = { backgroundColor : element.isResolve ? 'green':'red' }