当前位置:网站首页>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);
});
}
边栏推荐
- Location of package cache downloaded by unity packagemanager
- Visual Studio (VS) shortcut keys
- Unity Editor Extension - drag and drop
- Base64 and base64url
- Sequence of map implementation classes
- Binary to decimal, decimal to binary
- Encoding and decoding of golang URL
- Student educational administration management system of C # curriculum design
- Development material set
- 数据库原理期末复习
猜你喜欢

Unity4.3.1 engine source code compilation process

Display terrain database on osgearth ball

100 GIS practical application cases (78) - Multi compliance database design and data warehousing

Image processing 8-cnn image classification

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

数据分析练习题

Introduction to hexadecimal coding

【更新中】微信小程序学习笔记_3
![P1596 [USACO10OCT]Lake Counting S](/img/a7/07a84c93ee476788d9443c0add808b.png)
P1596 [USACO10OCT]Lake Counting S

Dealing with duplicate data in Excel with xlwings
随机推荐
php-fpm软件的安装+openresty高速缓存搭建
Creation and content of mapnode -- osgearth rendering engine series (2)
P1596 [USACO10OCT]Lake Counting S
Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données
Unity multi open script
Monotonic stack -84 The largest rectangle in the histogram
Animation_ IK overview
【Rust 笔记】08-枚举与模式
Conversion between golang JSON format and structure
单调栈-503. 下一个更大元素 II
How does unity fixedupdate call at a fixed frame rate
[concurrent programming] concurrent tool class of thread
OpenGL learning notes
Downward compatibility and upward compatibility
【云原生】微服务之Feign的介绍与使用
Some understandings of 3dfiles
Development material set
【音视频】ijkplayer错误码
数据分析练习题
Swagger document configuration