Uncaught TypeError: Cannot read property 'trim' of undefined

可以这样写,有值的时候trim,没值的时候为空

let user = this.state.name.trim() || '';

猜你喜欢

转载自www.cnblogs.com/luziluck/p/9254498.html