当前位置:网站首页>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);
});
}
边栏推荐
- Vscode, idea, VIM development tool shortcut keys
- UE4 source code reading_ Bone model and animation system_ Animation process
- UE4 call DLL
- 796 · unlock
- 【K&R】中文第二版 个人题解 Chapter1
- Monotonic stack -503 Next bigger Element II
- Osganimation library parsing
- Redis data structure
- Unity editor expansion - the framework and context of unity imgui
- Golang string segmentation, substitution and interception
猜你喜欢

Final review of Database Principles

Unity Editor Extension - drag and drop

单调栈-503. 下一个更大元素 II
![[updating] wechat applet learning notes_ three](/img/05/958b8d62d3a42b38ca1a2d8631a7f8.png)
[updating] wechat applet learning notes_ three

Simply start with the essence and principle of SOM neural network
![[redis] redis persistent RDB vs AOF (source code)](/img/57/b6a86c49cedee31fc00dc5d1372023.jpg)
[redis] redis persistent RDB vs AOF (source code)

matlab神經網絡所有傳遞函數(激活函數)公式詳解

Creation of osgearth earth files to the earth ------ osgearth rendering engine series (1)

详解sizeof、strlen、指针和数组等组合题

Thymeleaf 404 reports an error: there was unexpected error (type=not found, status=404)
随机推荐
Map的实现类的顺序性
单调栈-84. 柱状图中最大的矩形
Development experience and experience
Introduction to Base64 coding
Unity learning notes
分配异常的servlet
[rust notes] 06 package and module
【Rust 笔记】12-闭包
Solution détaillée de toutes les formules de fonction de transfert (fonction d'activation) du réseau neuronal MATLAB
swagger文档配置
Osgconv tool usage
796 · 开锁
796 · unlock
Osgearth starry background
[updating] wechat applet learning notes_ three
Advanced OSG collision detection
Animation_ IK overview
Clion toolchains are not configured configure disable profile problem solving
注解简化配置与启动时加载
OpenGL learning notes