当前位置:网站首页>JS ternary operator - learning notes (with cases)
JS ternary operator - learning notes (with cases)
2022-07-03 08:40:00 【Rain shallow listen to the wind sing】
Detailed explanation










react Case study

Hope to have color Attribute event Use color attribute , No, color The current time period of the attribute is gray , Then green
color:event.color?event.color:((new Date(event.start))>(new Date())?'green':'gray'),
onPageChange = (data: OnPageChangeData) => {
this.setState({
"eventList":{
}});
axios.post('api/oa/work/report/findMyAll', Qs.stringify({
start:moment(data.rangeFrom).format('YYYY-MM-DD HH:mm:ss'),
end:moment(data.rangeTo).format('YYYY-MM-DD HH:mm:ss')
}),{
headers: {
'Content-Type': 'application/x-www-form-urlencoded'}})
.then((response)=>{
let data=response.data.data;
for(let i=0;i<data.length;i++){
if(data[i]["type"]=='WEEK'){
data[i]["color"]='blue'
}
}
console.log(data)
let stateEventList=this.state.eventList;
for(let i=1;i<data.length;i++){
let event=data[i];
let eventDate=moment(event.start).format('DD-MM-YYYY HH:mm:ss').substring(0,10);
if (stateEventList[eventDate]==undefined){
let newEventList= new Array()
stateEventList[eventDate]=newEventList
}
let newEvent={
id:event.id,
startAt: moment(event.start).utc().format(),
endAt: moment(event.end).utc().format(),
summary: event.title,
type:event.type,
workContent:event.workContent,
// color:(new Date(event.start))>(new Date())?'green':'gray',
color:event.color?event.color:((new Date(event.start))>(new Date())?'green':'gray'),
};
stateEventList[eventDate].push(newEvent);
}
this.setState({
eventList:stateEventList})
console.log('this.eventList',this.eventList)
})
.catch(function (error) {
this.showErrorMessage(error);
});
}
边栏推荐
- How to deal with the core task delay caused by insufficient data warehouse resources
- GIS实战应用案例100篇(七十八)-多规合一数据库设计及数据入库
- Gradle's method of dynamically modifying APK package name
- Data analysis exercises
- Explain sizeof, strlen, pointer, array and other combination questions in detail
- Unity interactive water ripple post-treatment
- Ue5 opencv plug-in use
- Exe file running window embedding QT window
- UE4 source code reading_ Bone model and animation system_ Animation node
- [public key cryptography] ECC elliptic cryptosystem (implementing ElGamal encryption method)
猜你喜欢

XPath实现XML文档的查询

基于SSM的校园失物招领平台,源码,数据库脚本,项目导入运行视频教程,论文撰写教程

Kunlunbase meetup is waiting for you!

数据分析练习题

Message queue for interprocess communication

Simply start with the essence and principle of SOM neural network

Graphics_ Learnopongl learning notes

Ue5 opencv plug-in use
![P1596 [USACO10OCT]Lake Counting S](/img/a7/07a84c93ee476788d9443c0add808b.png)
P1596 [USACO10OCT]Lake Counting S

Final review of Database Principles
随机推荐
【Rust笔记】05-错误处理
[concurrent programming] consistency hash
二进制转十进制,十进制转二进制
[linear table] basic operation of bidirectional linked list specify node exchange
Collection interface
OpenGL learning notes
Dom4j遍历和更新XML
Simply start with the essence and principle of SOM neural network
如何应对数仓资源不足导致的核心任务延迟
Animation_ IK overview
Detailed explanation of all transfer function (activation function) formulas of MATLAB neural network
Unity editor expansion - scrolling list
Binary to decimal, decimal to binary
Installation of PHP FPM software +openresty cache construction
Display terrain database on osgearth ball
Osgearth starry background
数据库原理期末复习
[rust notes] 12 closure
【Rust 笔记】10-操作符重载
Location of package cache downloaded by unity packagemanager