黄子涵

查漏补缺——说说三目运算符

问题

如题所示

答案

相关源码:

const getters = {
    loading: state => state.loading,
    runTimeInterval: state => state.runTimeInterval,
    notice: state => state.websiteInfo?state.websiteInfo.notice:''
}

这里有一行关于三目运算符的代码:

 notice: state => state.websiteInfo?state.websiteInfo.notice:''

js中的三目运算符详解

根据上面,这句话的意思是当state.websiteInfo为真时,执行state.websiteInfo.notice,否则执行''

posted @ 2022-07-06 11:17  黄子涵  阅读(17)  评论(0编辑  收藏  举报