JS正则表达式验证非常全 //去除首尾空格 this.usernmae.replace(/^ss*/, '').replace(/ss*$/, ''); //全部空格 this.usernmae.replace(/s+/g,"");