查漏补缺——说说三目运算符
问题
如题所示
答案
相关源码:
const getters = {
loading: state => state.loading,
runTimeInterval: state => state.runTimeInterval,
notice: state => state.websiteInfo?state.websiteInfo.notice:''
}
这里有一行关于三目运算符的代码:
notice: state => state.websiteInfo?state.websiteInfo.notice:''
根据上面,这句话的意思是当state.websiteInfo
为真时,执行state.websiteInfo.notice
,否则执行''
。