可以这样写,有值的时候trim,没值的时候为空
let user = this.state.name.trim() || '';
posted on 2018-07-02 16:35 luziluck 阅读(4549) 评论(0) 编辑 收藏 举报