这样就可以了:xx=xx..replace(/(^\s*)|(\s*$)/g,"");另:去左空格replace(/(^\s*)/g, "");去右空格replace(/(\s*$)/g, ""); 中文全角空格不可以 相关文章: 2022-12-23 2022-12-23 2021-11-17 2021-06-09 2022-03-10