demo如下: let toShow = null; str = `<span ${a == null?'style="display:none"':'style="display:block"'}></span>`