如下代码哪种写法更好:
写法1:
const drawercStyle = { width: (show ? '100%' : '0') }const maskStyle = { width: (show? '100%' : '0'), opacity: (show ? '1' : '0') }
写法2:
if(show){ drawercStyle = { width: 100% } maskStyle = { opacity: 1 } }else{ drawercStyle = { width: 0 } maskStyle = { opacity: 0 } }
慕的地6264312
相关分类